Skip to content

associated type is unresolved when trait path is qualified. #11973

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
jhgg opened this issue Apr 13, 2022 · 5 comments
Closed

associated type is unresolved when trait path is qualified. #11973

jhgg opened this issue Apr 13, 2022 · 5 comments
Labels
A-nameres name, path and module resolution C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now

Comments

@jhgg
Copy link
Contributor

jhgg commented Apr 13, 2022

fn main() {}

trait T1 {
    type Bar;
    type Baz;
}

struct Foo;

mod t2 {
    pub trait T2 {
        type Bar;
    }
}

use t2::T2;

impl T2 for Foo {
    type Bar = String;
}

impl T1 for Foo {
    type Bar = <Foo as t2::T2>::Bar;
    //                          ^^^ unresolvedReference
    type Baz = <Foo as T2>::Bar;
    //                      ^^^ typeAlias
}

When T2 is used as t2::T2, Bar is unresolved, but when using T2 directly by getting it in scope w/ use t2::T2;, it is resolved properly.

rust-analyzer version: 14c86d5 2022-04-13 dev
rustc 1.60.0 (7737e0b5c 2022-04-04)

@lnicola
Copy link
Member

lnicola commented Apr 13, 2022

Probably dupe of #8282.

@jhgg
Copy link
Contributor Author

jhgg commented Apr 13, 2022

I swear I searched 🤣

@jhgg jhgg closed this as completed Apr 13, 2022
@jhgg
Copy link
Contributor Author

jhgg commented Apr 13, 2022

I don't think this is the same issue though, because 8282 has the trait in scope, where as this issue refers to it having a qualified path for the trait. I'll reopen but feel free to close if it is indeed dupe.

@jhgg jhgg reopened this Apr 13, 2022
@lnicola lnicola added S-actionable Someone could pick this issue up and work on it right now A-nameres name, path and module resolution C-bug Category: bug labels Apr 13, 2022
@bitgaoshu
Copy link
Contributor

I think the two is same. the both try to resolve a path fully. and the last segment is a assoc of trait.

@bitgaoshu
Copy link
Contributor

the diff is need to fix different method

@bors bors closed this as completed in c1de78f Apr 25, 2022
lnicola added a commit to lnicola/rust-analyzer that referenced this issue Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-nameres name, path and module resolution C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

3 participants