// check-fail // known-bug // This gives us problems because `for<'a> I::Item<'a>: Debug` should mean "for // all 'a where I::Item<'a> is WF", but really means "for all 'a possible" trait LendingIterator: Sized { type Item<'a> where Self: 'a; fn next(&mut self) -> Self::Item<'_>; } fn fails(iter: &mut I, f: F) -> bool where F: FnMut(I::Item<'_>), { let mut iter2 = Eat(iter, f); let _next = iter2.next(); //~^ borrowed data escapes true } impl LendingIterator for &mut I { type Item<'a> = I::Item<'a> where Self:'a; fn next(&mut self) -> Self::Item<'_> { (**self).next() } } struct Eat(I, F); impl Iterator for Eat where F: FnMut(I::Item<'_>), { type Item = (); fn next(&mut self) -> Option { None } } fn main() {}