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

Unable to do any definition lookups inside impl defined inside function #5382

Closed
jgarvin opened this issue Jul 14, 2020 · 1 comment
Closed

Comments

@jgarvin
Copy link

jgarvin commented Jul 14, 2020

In the main.rs below, you can't lookup anything inside the test() definition inside the impl. get, self, unwrap etc. all can't be found. rustc has no issue compiling it though.

#![allow(dead_code)]

use std::collections::HashMap;

trait Test {
    fn test(&self) -> i32;
}

fn foo() -> () {
    struct Foo {
        h: HashMap<i32, i32>
    }
    impl Test for Foo {
        fn test(&self) -> i32
        {
            return *self.h.get(&3).unwrap();
        }
    }
}

fn main() {
    println!("Hello, world!");
}

$ ~/opt/bin/rust-analyzer --version
rust-analyzer 5ca7cd9
@lnicola
Copy link
Member

lnicola commented Jul 14, 2020

Duplicate of #1559.

@lnicola lnicola closed this as completed Jul 14, 2020
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