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
Lifetimes get replaced with 'static in Self within (return position) impl Trait. #53613
error[E0308]: mismatched types
--> src/lib.rs:6:19
|
6 | || (self,self)
| ^^^^ lifetime mismatch
|
= note: expected type `Invariant<'static>`
found type `Invariant<'a>`
I didn't write 'static anywhere - it comes from part of the implementation of impl Trait, and Self references lifetimes (from the impl header) "indirectly", hiding them from impl Trait logic.
There is a variant of this problem that was revealed in #62221. If you write T::Item, and we expand that (in type-checking) to <T as Foo<'a>>::Item, the 'a is overlooked as well (playground):
pubtraitHasItem<'a>{typeItem;}// Does not compile:fnexample1<'a,T:HasItem<'a>>(item:T::Item) -> implIntoIterator<Item = T::Item>{Some(item)}// Compiles:fnexample2<'a,T:HasItem<'a>>(item:T::Item) -> implIntoIterator<Item = <TasHasItem<'a>>::Item>{Some(item)}fnmain(){}
I left some notes in this Zulip topic that explain one way to fix this problem. The idea is basically to detect Self during lowering and take it into account.
Just like #61949 I guess this is also fixed by #115659 ? The test case in the OP compiles fine today, other than needing to add move to the closure to make it move || (self, self)
Activity
nikomatsakis commentedon Jul 5, 2019
There is a variant of this problem that was revealed in #62221. If you write
T::Item, and we expand that (in type-checking) to<T as Foo<'a>>::Item, the'ais overlooked as well (playground):UPDATE: This is #51525
nikomatsakis commentedon Jul 9, 2019
I left some notes in this Zulip topic that explain one way to fix this problem. The idea is basically to detect
Selfduring lowering and take it into account.Auto merge of rust-lang#115659 - compiler-errors:itp, r=cjgillot
Auto merge of rust-lang#115659 - compiler-errors:itp, r=cjgillot
Auto merge of #115659 - compiler-errors:itp, r=cjgillot
Auto merge of #115659 - compiler-errors:itp, r=cjgillot
Auto merge of #115659 - compiler-errors:itp, r=cjgillot
Arnavion commentedon Aug 8, 2024
Just like #61949 I guess this is also fixed by #115659 ? The test case in the OP compiles fine today, other than needing to add
moveto the closure to make itmove || (self, self)Dylan-DPC commentedon Dec 15, 2024
Closing this as it's fixed and it compiles to a different error with indication on how to fix it by adding
moveto the closure.