]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/issue-91139.rs
Rollup merge of #94467 - ibraheemdev:master, r=pnkfelix
[rust.git] / src / test / ui / generic-associated-types / issue-91139.rs
1 #![feature(generic_associated_types)]
2
3 trait Foo<T> {
4     type Type<'a>
5     where
6         T: 'a;
7 }
8
9 impl<T> Foo<T> for () {
10     type Type<'a> = ()
11     where
12         T: 'a;
13 }
14
15 fn foo<T>() {
16     let _: for<'a> fn(<() as Foo<T>>::Type<'a>, &'a T) = |_, _| ();
17     //~^ ERROR `T` does not live long enough
18     //~| ERROR `T` does not live long enough
19     //~| ERROR `T` does not live long enough
20     //~| ERROR `T` does not live long enough
21     //~| ERROR `T` does not live long enough
22     //~| ERROR `T` does not live long enough
23     //~| ERROR `T` does not live long enough
24     //~| ERROR `T` does not live long enough
25     //~| ERROR `T` may not live long enough
26     //
27     // FIXME: This error is bogus, but it arises because we try to validate
28     // that `<() as Foo<T>>::Type<'a>` is valid, which requires proving
29     // that `T: 'a`. Since `'a` is higher-ranked, this becomes
30     // `for<'a> T: 'a`, which is not true. Of course, the error is bogus
31     // because there *ought* to be an implied bound stating that `'a` is
32     // not any lifetime but specifically
33     // "some `'a` such that `<() as Foo<T>>::Type<'a>" is valid".
34 }
35
36 pub fn main() {}