If I put the following in src/lib.rs
pub trait Foo {
type Bar: Default;
}
pub fn quux<T: Foo>() -> T::Bar {
let y = Default::default();
y
}
and open the project directory in Visual Studio Code (1.47.2), rust-analyzer (0.2.336, installed from the marketplace) annotates y
with the type
Foo::Bar<T>
which seems wrong to me -- surely the correct syntax is <T as Foo>::Bar
? If I click to insert the suggested type annotation, rustc indeed complains:
error[E0223]: ambiguous associated type
--> src/lib.rs:6:12
|
6 | let y: Foo::Bar<T> = Default::default();
| ^^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Foo>::Bar`
Is this a known issue? Am I missing something?