2 // ignore-compare-mode-nll
3 //[nll] compile-flags: -Z borrowck=mir
5 fn static_id<'a,'b>(t: &'a ()) -> &'static ()
6 where 'a: 'static { t }
7 //~^ WARN unnecessary lifetime parameter `'a`
9 fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static ()
10 where 'a: 'b, 'b: 'static { t }
11 //~^ WARN unnecessary lifetime parameter `'b`
13 fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
15 //[base]~^ ERROR E0312
16 //[nll]~^^ ERROR lifetime may not live long enough
19 fn error(u: &(), v: &()) {
21 //[base]~^ ERROR `u` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
22 //[nll]~^^ ERROR borrowed data escapes outside of function [E0521]
23 static_id_indirect(&v);
24 //[base]~^ ERROR `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
25 //[nll]~^^ ERROR borrowed data escapes outside of function [E0521]