4 clippy::needless_lifetimes,
5 clippy::needless_pass_by_value,
6 clippy::trivially_copy_pass_by_ref
8 #![warn(clippy::extra_unused_lifetimes)]
12 fn used_lt<'a>(x: &'a u8) {}
14 fn unused_lt<'a>(x: u8) {}
16 fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) {
17 // 'a is useless here since it's not directly bound
20 fn lt_return<'a, 'b: 'a>(x: &'b u8) -> &'a u8 {
24 fn lt_return_only<'a>() -> &'a u8 {
28 fn unused_lt_blergh<'a>(x: Option<Box<dyn Send + 'a>>) {}
31 fn x(&self, a: &'a u8);
34 impl<'a> Foo<'a> for u8 {
35 fn x(&self, a: &'a u8) {}
44 // test for #489 (used lifetimes in bounds)
45 pub fn parse<'a, I: Iterator<Item = &'a str>>(_it: &mut I) {
48 pub fn parse2<'a, I>(_it: &mut I)
50 I: Iterator<Item = &'a str>,
60 fn self_ref_with_lifetime<'a>(&'a self) {}
61 fn explicit_self_with_lifetime<'a>(self: &'a Self) {}
64 // Methods implementing traits must have matching lifetimes
67 pub struct Foo<'a>(&'a std::marker::PhantomData<u8>);
70 pub struct Bar<'a: 'b, 'b>(Foo<'a>, &'b std::marker::PhantomData<u8>);
73 fn test<'a: 'b, 'b>(foo: &Foo<'a>, bar: &Bar<'a, 'b>);
79 fn test<'a: 'b, 'b>(_foo: &Foo, _bar: &Bar) {}