2016-05-10 10:46:56 -04:00
|
|
|
// 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.
|
|
|
|
|
2025-04-12 22:40:34 +03:00
|
|
|
//@ dont-require-annotations: NOTE
|
2016-05-10 10:46:56 -04:00
|
|
|
|
|
|
|
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() {
|
2024-12-04 03:19:03 -08:00
|
|
|
x.unwrap()
|
2016-05-10 10:46:56 -04:00
|
|
|
} else {
|
2024-12-04 03:19:03 -08:00
|
|
|
mk_static() //~ ERROR lifetime may not live long enough
|
2025-04-12 22:40:34 +03:00
|
|
|
//~| NOTE assignment requires that `'a` must outlive `'static`
|
2016-05-10 10:46:56 -04:00
|
|
|
};
|
|
|
|
f(bad);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|