]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Test that an invariant region parameter used in a contravariant way |
2 | // yields an error. | |
3 | // | |
4 | // Note: see variance-regions-*.rs for the tests that check that the | |
5 | // variance inference works in the first place. | |
6 | ||
7 | struct Invariant<'a> { | |
8 | f: &'a mut &'a isize | |
9 | } | |
10 | ||
11 | fn use_<'short,'long>(c: Invariant<'long>, | |
12 | s: &'short isize, | |
13 | l: &'long isize, | |
14 | _where:Option<&'short &'long ()>) { | |
15 | ||
16 | // Test whether Invariant<'long> <: Invariant<'short>. Since | |
17 | // 'short <= 'long, this would be true if the Invariant type were | |
18 | // contravariant with respect to its parameter 'a. | |
19 | ||
04454e1e | 20 | let _: Invariant<'short> = c; |
923072b8 | 21 | //~^ ERROR lifetime may not live long enough |
1a4d82fc JJ |
22 | } |
23 | ||
24 | fn main() { } |