about summary refs log tree commit diff
path: root/tests/ui/regions/region-invariant-static-error-reporting.rs
blob: 9792c101fa89458b87df4b503570e7aba1fb21bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// This test checks that the error messages you get for this example
// at least mention `'a` and `'static`. The precise messages can drift
// over time, but this test used to exhibit some pretty bogus messages
// that were not remotely helpful.

//@ dont-require-annotations: NOTE

struct Invariant<'a>(Option<&'a mut &'a mut ()>);

fn mk_static() -> Invariant<'static> { Invariant(None) }

fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
    let bad = if x.is_some() {
        x.unwrap()
    } else {
        mk_static() //~ ERROR lifetime may not live long enough
                    //~| NOTE assignment requires that `'a` must outlive `'static`
    };
    f(bad);
}

fn main() {}