Rust-analyzer seems to suggest bad syntax for associated type

If I put the following in src/

pub trait Foo {
    type Bar: Default;

pub fn quux<T: Foo>() -> T::Bar {
    let y = Default::default();


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


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/
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?

Sounds weird. I would check the issue tracker of the project.

1 Like

I didn't see any obvious duplicates in the tracker so I've opened Thanks for the sanity check!

ETA: a maintainer has confirmed the issue and outlined a fix, so I'm going to mark this as solved.