First of all, thanks for a very useful tool!
When I edit the following code:
pub trait Foo {
type Bar: Default;
}
pub fn quux<T: Foo>() -> T::Bar {
let y = Default::default();
y
}
rust-analyzer annotates y with the nonsensical type Foo::Bar<T>, instead of the correct <T as Foo>::Bar. Clicking to insert this annotation results in a compilation error as expected (E0223).
I'm using Visual Studio Code 1.47.2 with version 0.2.336 of the rust-analyzer plugin (installed from the marketplace) and the latest stable rustc. I have not installed the official Rust plugin.
Foo::Bar<T> is how RA and Chalk internally represent the placeholder type that gets used when the projection <T as Foo>::Bar can't be normalized to any concrete type. The problem here is that the code that displays the type hints wasn't originally intended to produce actual syntax, rather to accurately represent each type. We could special case the code here to print a projection if f.display_target.is_source_code(), though long-term my idea is to do this by turning the Ty back into a HIR that's closer to actual source code.
I will try to resolve this issue if you don't mind, as there is some instructions thanks to @flodiebold and I haven't already explore this part of the codebase
Most helpful comment
I will try to resolve this issue if you don't mind, as there is some instructions thanks to @flodiebold and I haven't already explore this part of the codebase