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

Type inference fails with local 'use Trait', but works with top-level one #4619

Closed
Vlad-Shcherbina opened this issue May 26, 2020 · 1 comment

Comments

@Vlad-Shcherbina
Copy link
Contributor

To reproduce

  1. Open the following program in VSCode:
    // [dependencies]
    // rand = "0.7"
    
    use rand::seq::SliceRandom;
    fn main() {
        let x = [1].choose(&mut rand::thread_rng());
    }
  2. Mouse hover over "x".
  3. Now change change the program to
    fn main() {
        use rand::seq::SliceRandom;
        let x = [1].choose(&mut rand::thread_rng());
    }
  4. Mouse hover over "x" again.

Expected result

In both cases x: Option<&i32>.

Actual result

In the first case x: Option<&i32>, in the second x: {unknown}.

rust-analyzer version: 2020-05-25 (fbb8b88)
@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