]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-static-bound.rs
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
[rust.git] / src / test / ui / regions / regions-static-bound.rs
1 // revisions: base nll
2 // ignore-compare-mode-nll
3 //[nll] compile-flags: -Z borrowck=mir
4
5 fn static_id<'a,'b>(t: &'a ()) -> &'static ()
6     where 'a: 'static { t }
7 //~^ WARN unnecessary lifetime parameter `'a`
8
9 fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static ()
10     where 'a: 'b, 'b: 'static { t }
11 //~^ WARN unnecessary lifetime parameter `'b`
12
13 fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
14     t
15     //[base]~^ ERROR E0312
16     //[nll]~^^ ERROR lifetime may not live long enough
17 }
18
19 fn error(u: &(), v: &()) {
20     static_id(&u);
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]
26 }
27
28 fn main() {}