mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
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>
29 lines
667 B
Rust
29 lines
667 B
Rust
// run-pass
|
|
|
|
#![warn(unused_lifetimes)]
|
|
|
|
fn invariant_id<'a,'b>(t: &'b mut &'static ()) -> &'b mut &'a ()
|
|
where 'a: 'static { t }
|
|
//~^ WARN unnecessary lifetime parameter `'a`
|
|
|
|
fn static_id<'a>(t: &'a ()) -> &'static ()
|
|
where 'a: 'static { t }
|
|
//~^ 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 ref_id<'a>(t: &'a ()) -> &'a () where 'static: 'a { t }
|
|
|
|
static UNIT: () = ();
|
|
|
|
fn main()
|
|
{
|
|
let mut val : &'static () = &UNIT;
|
|
invariant_id(&mut val);
|
|
static_id(val);
|
|
static_id_indirect(val);
|
|
ref_id(val);
|
|
}
|