diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs b/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs new file mode 100644 index 000000000..8e6c5348e --- /dev/null +++ b/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs @@ -0,0 +1,40 @@ +// 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<I: LendingIterator, F>(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<I: LendingIterator> 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>(I, F); +impl<I: LendingIterator, F> Iterator for Eat<I, F> +where + F: FnMut(I::Item<'_>), +{ + type Item = (); + fn next(&mut self) -> Option<Self::Item> { + None + } +} + +fn main() {} |