ce2ae62d68
Define the `named_static_lifetimes` lint This lint will replace the existing hard-warning. Replace the named static lifetime hard-warning with the new lint Update the UI tests for the `named_static_lifetimes` lint Remove the direct dependency on `rustc_lint_defs` fix build Signed-off-by: Zhi Qi <qizhi@pingcap.com> use "UNUSED_LIFETIMES" instead Signed-off-by: Zhi Qi <qizhi@pingcap.com> update 1 test and fix typo Signed-off-by: Zhi Qi <qizhi@pingcap.com> update tests Signed-off-by: Zhi Qi <qizhi@pingcap.com> fix tests: add extra blank line Signed-off-by: Zhi Qi <qizhi@pingcap.com>
24 lines
679 B
Rust
24 lines
679 B
Rust
#![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`
|
|
|
|
fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static ()
|
|
where 'a: 'b, 'b: 'static { t }
|
|
//~^ WARN unnecessary lifetime parameter `'b`
|
|
|
|
fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
|
|
t
|
|
//~^ ERROR lifetime may not live long enough
|
|
}
|
|
|
|
fn error(u: &(), v: &()) {
|
|
static_id(&u);
|
|
//~^ ERROR borrowed data escapes outside of function [E0521]
|
|
static_id_indirect(&v);
|
|
//~^ ERROR borrowed data escapes outside of function [E0521]
|
|
}
|
|
|
|
fn main() {}
|