1 // aux-build:proc_macro_derive.rs
6 clippy::needless_lifetimes,
7 clippy::needless_pass_by_value,
8 clippy::needless_arbitrary_self_type
10 #![warn(clippy::extra_unused_lifetimes)]
13 extern crate proc_macro_derive;
17 fn used_lt<'a>(x: &'a u8) {}
19 fn unused_lt<'a>(x: u8) {}
21 fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) {
22 // 'a is useless here since it's not directly bound
25 fn lt_return<'a, 'b: 'a>(x: &'b u8) -> &'a u8 {
29 fn lt_return_only<'a>() -> &'a u8 {
33 fn unused_lt_blergh<'a>(x: Option<Box<dyn Send + 'a>>) {}
36 fn x(&self, a: &'a u8);
39 impl<'a> Foo<'a> for u8 {
40 fn x(&self, a: &'a u8) {}
49 // test for #489 (used lifetimes in bounds)
50 pub fn parse<'a, I: Iterator<Item = &'a str>>(_it: &mut I) {
53 pub fn parse2<'a, I>(_it: &mut I)
55 I: Iterator<Item = &'a str>,
65 fn self_ref_with_lifetime<'a>(&'a self) {}
66 fn explicit_self_with_lifetime<'a>(self: &'a Self) {}
69 // Methods implementing traits must have matching lifetimes
72 fn unused_lt<'a>(x: u8) {}
75 impl BadTrait for () {
76 fn unused_lt<'a>(_x: u8) {}
83 impl<'a> std::ops::AddAssign<&Scalar> for &mut Scalar {
84 fn add_assign(&mut self, _rhs: &Scalar) {
90 pub fn something<'c>() -> Self {
96 // https://github.com/rust-lang/rust-clippy/pull/8737#pullrequestreview-951268213
98 use serde::de::Visitor;
100 fn fmt(&self, formatter: &mut std::fmt::Formatter);
103 impl<'de, T> Expected for T
107 fn fmt(&self, formatter: &mut std::fmt::Formatter) {}
111 // https://github.com/rust-lang/rust-clippy/pull/8737#pullrequestreview-951268213
117 impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
123 #[derive(ExtraLifetimeDerive)]