]>
Commit | Line | Data |
---|---|---|
85aaf69f SL |
1 | // Test that structs with higher-ranked where clauses don't generate |
2 | // "outlives" requirements. Issue #22246. | |
3 | ||
4 | #![allow(dead_code)] | |
a1dfa0c6 | 5 | |
9346a6ac | 6 | pub trait TheTrait<'b> { |
85aaf69f SL |
7 | type TheAssocType; |
8 | } | |
9 | ||
10 | pub struct TheType<'b> { | |
11 | m: [fn(&'b()); 0] | |
12 | } | |
13 | ||
14 | impl<'a,'b> TheTrait<'a> for TheType<'b> { | |
15 | type TheAssocType = &'b (); | |
16 | } | |
17 | ||
85aaf69f SL |
18 | pub struct WithHrAssoc<T> |
19 | where for<'a> T : TheTrait<'a> | |
20 | { | |
21 | m: [T; 0] | |
22 | } | |
23 | ||
24 | fn with_assoc<'a,'b>() { | |
b039eaaf | 25 | // We get an error because 'b:'a does not hold: |
85aaf69f SL |
26 | |
27 | let _: &'a WithHrAssoc<TheType<'b>> = loop { }; | |
923072b8 | 28 | //~^ ERROR lifetime may not live long enough |
85aaf69f SL |
29 | } |
30 | ||
85aaf69f SL |
31 | pub trait TheSubTrait : for<'a> TheTrait<'a> { |
32 | } | |
33 | ||
34 | impl<'b> TheSubTrait for TheType<'b> { } | |
35 | ||
36 | pub struct WithHrAssocSub<T> | |
37 | where T : TheSubTrait | |
38 | { | |
39 | m: [T; 0] | |
40 | } | |
41 | ||
42 | fn with_assoc_sub<'a,'b>() { | |
e9174d1e SL |
43 | // The error here is just because `'b:'a` must hold for the type |
44 | // below to be well-formed, it is not related to the HR relation. | |
85aaf69f SL |
45 | |
46 | let _: &'a WithHrAssocSub<TheType<'b>> = loop { }; | |
923072b8 | 47 | //~^ ERROR lifetime may not live long enough |
85aaf69f SL |
48 | } |
49 | ||
a1dfa0c6 | 50 | |
e9174d1e | 51 | fn main() { |
85aaf69f | 52 | } |