summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/regions-variance-invariant-use-contravariant.rs
blob: a81aaa9c776f5fb2199858226df6ff263f5176df (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
// Test that an invariant region parameter used in a contravariant way
// yields an error.
//
// Note: see variance-regions-*.rs for the tests that check that the
// variance inference works in the first place.

struct Invariant<'a> {
    f: &'a mut &'a isize
}

fn use_<'short,'long>(c: Invariant<'long>,
                      s: &'short isize,
                      l: &'long isize,
                      _where:Option<&'short &'long ()>) {

    // Test whether Invariant<'long> <: Invariant<'short>.  Since
    // 'short <= 'long, this would be true if the Invariant type were
    // contravariant with respect to its parameter 'a.

    let _: Invariant<'short> = c;
    //~^ ERROR lifetime may not live long enough
}

fn main() { }