2023-02-21 19:41:48 -06:00
|
|
|
#![warn(unused_lifetimes)]
|
|
|
|
|
|
|
|
fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t }
|
|
|
|
//~^ WARN lifetime parameter `'b` never used
|
|
|
|
//~| WARN unnecessary lifetime parameter `'a`
|
2022-03-14 09:56:37 -05:00
|
|
|
|
2015-07-06 12:40:12 -05:00
|
|
|
fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static ()
|
|
|
|
where 'a: 'b, 'b: 'static { t }
|
2022-03-14 09:56:37 -05:00
|
|
|
//~^ WARN unnecessary lifetime parameter `'b`
|
|
|
|
|
2015-07-06 12:40:12 -05:00
|
|
|
fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
|
2022-04-19 05:56:18 -05:00
|
|
|
t
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2015-07-06 12:40:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn error(u: &(), v: &()) {
|
2022-04-19 05:56:18 -05:00
|
|
|
static_id(&u);
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR borrowed data escapes outside of function [E0521]
|
2022-04-19 05:56:18 -05:00
|
|
|
static_id_indirect(&v);
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR borrowed data escapes outside of function [E0521]
|
2015-07-06 12:40:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|