Skip to content
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

use statements in blocks are not used to inform autocompletion or type inference #5335

Closed
zrneely opened this issue Jul 12, 2020 · 1 comment

Comments

@zrneely
Copy link

zrneely commented Jul 12, 2020

I noticed that use statements that occur inside blocks are not being used to inform autocompletion or type inference. For example, this doesn't give completions or display types on file. or File:::

fn main() {
    let result = {
        use std::{fs::File, io::Read};

        let mut file = File::open("test.txt").unwrap();
        let mut buf = [0; 16];
        file.read_exact(&mut buf[..]).unwrap();
        buf
    };
}

image

Whereas this does:

use std::{fs::File, io::Read};

fn main() {
    let result = {
        let mut file = File::open("test.txt").unwrap();
        let mut buf = [0; 16];
        file.read_exact(&mut buf[..]).unwrap();
        buf
    };
}

image

I noticed this while using the rust-analyzer plugin for VS Code, version 0.2.232. Apologies if this is a duplicate issue or isn't sufficiently descriptive. I'm a happy user of rust-analyzer, but I don't have much knowledge about commonly used terminology so I may have missed something while searching the issue tracker.

@flodiebold
Copy link
Member

Duplicate of #1165.

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

2 participants