]> git.lizzy.rs Git - rust.git/blob - tests/ui/generic-associated-types/bugs/issue-88382.rs
Rollup merge of #107112 - eltociear:patch-19, r=albertlarsan68
[rust.git] / tests / ui / generic-associated-types / bugs / issue-88382.rs
1 // check-fail
2 // known-bug: #88382
3
4 // This should pass, but has a missed normalization due to HRTB.
5
6 trait Iterable {
7     type Iterator<'a> where Self: 'a;
8     fn iter(&self) -> Self::Iterator<'_>;
9 }
10
11 struct SomeImplementation();
12
13 impl Iterable for SomeImplementation {
14     type Iterator<'a> = std::iter::Empty<usize>;
15     fn iter(&self) -> Self::Iterator<'_> {
16         std::iter::empty()
17     }
18 }
19
20 fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>)) {
21     f(&mut i.iter());
22 }
23
24 fn main() {
25     do_something(SomeImplementation(), |_| ());
26     do_something(SomeImplementation(), test);
27 }
28
29 fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}