You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When referring to BarEnum as Self::Bar, rust-analyzer seems to be unable to resolve. Here is a screenshot with a red semantic token.
This breaks autocomplete, and also stuff like rename symbol, for example renaming BarEnum::Qux, does not cause Self::Bar::Qux to be renamed. Additionally renaming type Bar also does not rename where its unresilved.
Self::Bar only becomes unresolved after you type :: after it:
lowr
added
A-nameres
name, path and module resolution
A-hir
hir and hir-def related
A-ty
type system / type inference / traits / method resolution
labels
Mar 24, 2023
…r=HKalbasi
Normalize associated types in paths in expressions
Part of #14393
When we resolve paths in expressions (either path expressions or paths in struct expressions), there's a need of projection normalization, which `TyLoweringContext` cannot do on its own. We've been properly applying normalization for paths in struct expressions without type anchor, but not for others:
```rust
enum E {
S { v: i32 }
Empty,
}
impl Foo for Bar {
type Assoc = E;
fn foo() {
let _ = Self::Assoc::S { v: 42 }; // path in struct expr without type anchor; we already support this
let _ = <Self>::Assoc::S { v: 42 }; // path in struct expr with type anchor; resolves with this PR
let _ = Self::Assoc::Empty; // path expr; resolves with this PR
}
}
```
With this PR we correctly resolve the whole path, but we need some more tweaks in HIR and/or IDE layers to properly resolve a qualifier (prefix) of such paths and provide IDE features that are pointed out in #14393 to be currently broken.
I'm not sure the best title for this issue, so feel free to rename:
Consider the following code:
When referring to
BarEnum
asSelf::Bar
, rust-analyzer seems to be unable to resolve. Here is a screenshot with a red semantic token.This breaks autocomplete, and also stuff like rename symbol, for example renaming
BarEnum::Qux
, does not causeSelf::Bar::Qux
to be renamed. Additionally renamingtype Bar
also does not rename where its unresilved.Self::Bar
only becomes unresolved after you type::
after it:rust-analyzer version: rust-analyzer version: 0.4.1445-standalone
rustc version: rustc 1.66.1 (90743e729 2023-01-10)
The text was updated successfully, but these errors were encountered: