GAT(Generic Associated Type) used in bound of another GAT

I'm trying to use GATs for a small personal project (I know that I probably shouldn't). So far it worked, but now I'm having an error, which I don't understand. Here is an example.

Here is the error:

error[E0271]: type mismatch resolving `for<'a> <<FooImpl as Foo>::Bar<'a> as Bar>::Baz == <FooImpl as Foo>::Baz<'a>`
 --> src/
42 |     type Baz<'a> = MyBaz<'a>;
  |                    ^^^^^^^^^ expected struct `MyBaz`, found associated type
  = note:       expected struct `MyBaz<'_>`
          found associated type `<FooImpl as Foo>::Baz<'_>`
  = help: consider constraining the associated type `<FooImpl as Foo>::Baz<'_>` to `MyBaz<'_>`
  = note: for more information, visit

What am I doing wrong?

GATs are far from complete, and are unsound, I would avoid them till more work is done


Interpreting the error, I think the compiler is failing to resolve <FooImpl as Foo>::Baz<'a>, and isn't realizing that it is actually specified as MyBaz<'a>.

As far as what you did wrong, I don't think you did anything wrong. As @RustyYato stated, this is simply generic associated type support being incomplete.

1 Like

Thank you for your help!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.