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
{{ message }}
Repository navigation
GAT: lifetime is inconsistently required with Higher-Rank Trait Bounds #93262
This was working fine with rustc 1.58. Now with 1.60 I get the following error message:
error[E0311]: the parameter type `T` may not live long enough
--> src/lib.rs:13:16
|
13 | impl<T: Trait> Foo<T> for Type
| -- ^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
| |
| help: consider adding an explicit lifetime bound...: `T: 'a +`
|
note: ...that is required by this bound
--> src/lib.rs:8:38
|
8 | for<'a> <T as Trait>::Assoc<'a>: Clone
| ^^^^^
There are a couple of weird things going on:
First, it was my understanding that the for<'a> <T as Trait>::Assoc<'a>: ... bound is well formed and should be accepted by the compiler even though the where Self: 'a bound on Trait::Assoc means that T must outlive 'a. I might be wrong here.
The error message disappears if we remove the HRTB from the trait definition but not from the trait implementation.
We can define a function with the same HRTB, and it compiles fine:
Activity
compiler-errors commentedon Apr 14, 2022
This is due to #92191
Rollup merge of rust-lang#96593 - jackh726:issue-93262, r=compiler-er…
Auto merge of rust-lang#96593 - jackh726:issue-93262, r=compiler-errors