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