Skip to content

Types not inferred for some arguments in function call hint e.g. Option<_> #5843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jamesmcm opened this issue Aug 22, 2020 · 7 comments
Closed

Comments

@jamesmcm
Copy link

Hi,

See this example: https://i.imgur.com/ISVhf2B.png

This is with rust-analyzer built from the master branch of this repo, and using coc-rust-analyzer in neovim.

The full function signature is:

fn send_email(
    recipient: &str,
    subject: &str,
    plain_body: &str,
    html_body: Option<&str>,
    attachment: Option<Attachment>,
    ses_client: &SesClient,
    rt: &mut tokio::runtime::Runtime,
) -> Result<()> 

defined in the same source file.

Where Result there is anyhow::Result

It fails to show the types for both Option<_> cases.

I'd be happy to contribute but I'm not sure where to start, even for just getting debug info when using coc and neovim on Linux.

Looking at the code, it seems the relevant part might be the lowering to LSP types in hir_ty/src/lower.rs.

@bjorn3
Copy link
Member

bjorn3 commented Aug 22, 2020

Do you have the rust-src rustup component installed?

@jamesmcm
Copy link
Author

Yep:

[18:36] archie | rustup component list
cargo-x86_64-unknown-linux-gnu (installed)
clippy-x86_64-unknown-linux-gnu (installed)
llvm-tools-preview-x86_64-unknown-linux-gnu
miri-x86_64-unknown-linux-gnu
rls-x86_64-unknown-linux-gnu
rust-analysis-x86_64-unknown-linux-gnu
rust-analyzer-preview-x86_64-unknown-linux-gnu
rust-docs-x86_64-unknown-linux-gnu (installed)
rust-src (installed)

@flodiebold
Copy link
Member

This does look like rust-analyzer can't find the standard library. If you do something like

fn main() {
    let x = Some(1);
    x.
}

do you get completions? I'd guess not.

Do you have RUST_SRC_PATH set? Are you seeing any error messages in the rust-analyzer logs?

@jamesmcm
Copy link
Author

Fixed: https://i.imgur.com/4TyFbdI.png

So the issue was I had some old settings from RLS, that were interfering. So I just removed the setting for RUST_SRC_PATH entirely and now it's okay.

Strangely rust-src didn't install to ~/.rustup/toolchain/TOOLCHAIN/lib/rustlib/src/rust/src but instead to like ~/.rustup/toolchain/TOOLCHAIN/lib/rustlib/src/rust/library - is that a change from the past?

@jamesmcm
Copy link
Author

But for future reference, how can I check the rust-analyzer logs in cases like this?

@lnicola
Copy link
Member

lnicola commented Aug 23, 2020

See #5586.

I'm not sure where the logs show up in vim, Code has a tool window for them.

@jamesmcm
Copy link
Author

Thanks! I'll close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants