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 switching to type AT<'b> = T::AT<'a>, the correct error is given, but the hint is not provided.
#![feature(generic_associated_types)]traitMyTrait{typeAT<'a>whereSelf:'a;fnselfreffing<'a>(&'aself) -> Self::AT<'a>{unimplemented!();}}structInner;implMyTraitforInner{typeAT<'b>whereSelf:'b = ();}structOuter<'a,T>(&'aT);impl<'a,T:MyTrait>MyTraitforOuter<'a,T>{typeAT<'b> = T::AT<'a>;// Should recommend type AT<'b> where Self: 'b = T::AT<'a>;}
error[E0477]: the type `Outer<'a, T>` does not fulfill the required lifetime
--> src/lib.rs:16:5
|
16 | type AT<'b> = T::AT<'a>;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
note: type must outlive the lifetime `'b` as defined here
--> src/lib.rs:16:13
|
16 | type AT<'b> = T::AT<'a>;
| ^^
For more information about this error, try `rustc --explain E0477`.
GATs issue triage: not blocking. I don't like that this diagnostic is just wrong. The "easy" fix here would be to disable the "consider adding a where clause" help if that where clause isn't on the trait, but a proper fix would be able to suggest Self: 'a. Either way, this is just poor diagnostics and doesn't miscompile.
error[[E0309]](https://doc.rust-lang.org/nightly/error_codes/E0309.html): the parameter type `T` may not live long enough
--> src/lib.rs:16:19
|
16 | type AT<'b> = T::AT<'b>;
| ^^^^^^^^^- help: consider adding a where clause: `where T: 'b`
| |
| ...so that the type `T` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> src/lib.rs:4:29
|
4 | type AT<'a> where Self: 'a;
| ^^
For more information about this error, try `rustc --explain E0309`.
Activity
vandenheuvel commentedon Nov 12, 2021
When switching to
type AT<'b> = T::AT<'a>, the correct error is given, but the hint is not provided.Playground
jackh726 commentedon Dec 14, 2021
GATs issue triage: not blocking. I don't like that this diagnostic is just wrong. The "easy" fix here would be to disable the "consider adding a where clause" help if that where clause isn't on the trait, but a proper fix would be able to suggest
Self: 'a. Either way, this is just poor diagnostics and doesn't miscompile.Auto merge of rust-lang#96709 - jackh726:gats-stabilization, r=compil…
Auto merge of rust-lang#96709 - jackh726:gats-stabilization, r=compil…
Dylan-DPC commentedon May 3, 2023
Current output: