summaryrefslogtreecommitdiffstats
path: root/src/test/ui/generic-associated-types/bugs/issue-88382.rs
blob: 5493b9b9391359926e2525f432bccac390e6a0aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// check-fail
// known-bug: #88382

// This should pass, but has a missed normalization due to HRTB.

#![feature(generic_associated_types)]

trait Iterable {
    type Iterator<'a> where Self: 'a;
    fn iter(&self) -> Self::Iterator<'_>;
}

struct SomeImplementation();

impl Iterable for SomeImplementation {
    type Iterator<'a> = std::iter::Empty<usize>;
    fn iter(&self) -> Self::Iterator<'_> {
        std::iter::empty()
    }
}

fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>)) {
    f(&mut i.iter());
}

fn main() {
    do_something(SomeImplementation(), |_| ());
    do_something(SomeImplementation(), test);
}

fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}