2023-12-16 01:58:26 +00:00
|
|
|
#![warn(unused_lifetimes, redundant_lifetimes)]
|
2023-11-29 02:41:31 +00:00
|
|
|
|
2023-02-22 01:41:48 +00:00
|
|
|
fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t }
|
2023-11-29 02:41:31 +00:00
|
|
|
//~^ WARN unnecessary lifetime parameter `'a`
|
|
|
|
//~| WARN lifetime parameter `'b` never used
|
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 ()
|
2023-11-29 02:41:31 +00:00
|
|
|
//~^ WARN unnecessary lifetime parameter `'a`
|
|
|
|
//~| WARN unnecessary lifetime parameter `'b`
|
2015-07-06 17:40:12 +00:00
|
|
|
where 'a: 'b, 'b: 'static { t }
|
2022-03-14 14:56:37 +00:00
|
|
|
|
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() {}
|