]> git.lizzy.rs Git - rust.git/blob - tests/ui/generic-associated-types/bugs/hrtb-implied-2.rs
8e6c5348e71cab2194056bdb3d980a0ccc99fb8c
[rust.git] / tests / ui / generic-associated-types / bugs / hrtb-implied-2.rs
1 // check-fail
2 // known-bug
3
4 // This gives us problems because `for<'a> I::Item<'a>: Debug` should mean "for
5 // all 'a where I::Item<'a> is WF", but really means "for all 'a possible"
6
7 trait LendingIterator: Sized {
8     type Item<'a>
9     where
10         Self: 'a;
11     fn next(&mut self) -> Self::Item<'_>;
12 }
13 fn fails<I: LendingIterator, F>(iter: &mut I, f: F) -> bool
14 where
15     F: FnMut(I::Item<'_>),
16 {
17     let mut iter2 = Eat(iter, f);
18     let _next = iter2.next();
19     //~^ borrowed data escapes
20     true
21 }
22 impl<I: LendingIterator> LendingIterator for &mut I {
23     type Item<'a> = I::Item<'a> where Self:'a;
24     fn next(&mut self) -> Self::Item<'_> {
25         (**self).next()
26     }
27 }
28
29 struct Eat<I, F>(I, F);
30 impl<I: LendingIterator, F> Iterator for Eat<I, F>
31 where
32     F: FnMut(I::Item<'_>),
33 {
34     type Item = ();
35     fn next(&mut self) -> Option<Self::Item> {
36         None
37     }
38 }
39
40 fn main() {}