1 #![deny(single_use_lifetimes)]
3 #![allow(unused_variables)]
5 // Test that we DO warn when lifetime name is used only
6 // once in a fn argument.
8 fn a<'a>(x: &'a u32) { //~ ERROR `'a` only used once
9 //~^ HELP elide the single-use lifetime
12 struct Single<'a> { x: &'a u32 }
13 struct Double<'a, 'b> { f: &'a &'b u32 }
15 fn center<'m>(_: Single<'m>) {} //~ ERROR `'m` only used once
16 //~^ HELP elide the single-use lifetime
17 fn left<'x, 'y>(foo: Double<'x, 'y>) -> &'x u32 { foo.f } //~ ERROR `'y` only used once
18 //~^ HELP elide the single-use lifetime
19 fn right<'x, 'y>(foo: Double<'x, 'y>) -> &'y u32 { foo.f } //~ ERROR `'x` only used once
20 //~^ HELP elide the single-use lifetime
24 // Do NOT lint in an HRTB.
25 pub fn g<T: for<'a> Tfv<'a>>() {}
27 // Do NOT lint for trait bounds.