]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/region-invariant-static-error-reporting.rs
Use the same message as type & const generics.
[rust.git] / src / test / ui / regions / region-invariant-static-error-reporting.rs
1 // This test checks that the error messages you get for this example
2 // at least mention `'a` and `'static`. The precise messages can drift
3 // over time, but this test used to exhibit some pretty bogus messages
4 // that were not remotely helpful.
5
6 // revisions: base nll
7 // ignore-compare-mode-nll
8 //[base] error-pattern:the lifetime `'a`
9 //[base] error-pattern:the static lifetime
10 //[nll] compile-flags: -Z borrowck=mir
11 //[nll] error-pattern:argument requires that `'a` must outlive `'static`
12
13 struct Invariant<'a>(Option<&'a mut &'a mut ()>);
14
15 fn mk_static() -> Invariant<'static> { Invariant(None) }
16
17 fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
18     let bad = if x.is_some() {
19         x.unwrap() //[nll]~ ERROR borrowed data escapes outside of function [E0521]
20     } else {
21         mk_static() //[base]~ ERROR `if` and `else` have incompatible types [E0308]
22     };
23     f(bad);
24 }
25
26 fn main() {}