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