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