]> git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/region-invariant-static-error-reporting.rs
New upstream version 1.63.0+dfsg1
[rustc.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 // error-pattern:argument requires that `'a` must outlive `'static`
7
8 struct Invariant<'a>(Option<&'a mut &'a mut ()>);
9
10 fn mk_static() -> Invariant<'static> { Invariant(None) }
11
12 fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
13 let bad = if x.is_some() {
14 x.unwrap() //~ ERROR borrowed data escapes outside of function [E0521]
15 } else {
16 mk_static()
17 };
18 f(bad);
19 }
20
21 fn main() {}