File tree Expand file tree Collapse file tree 3 files changed +32
-6
lines changed Expand file tree Collapse file tree 3 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -72,3 +72,17 @@ pub fn mini_macro(_: TokenStream) -> TokenStream {
7272 }
7373 )
7474}
75+
76+ #[ proc_macro_derive( ExtraLifetimeDerive ) ]
77+ #[ allow( unused) ]
78+ pub fn extra_lifetime ( _input : TokenStream ) -> TokenStream {
79+ quote ! (
80+ pub struct ExtraLifetime ;
81+
82+ impl <' b> ExtraLifetime {
83+ pub fn something<' c>( ) -> Self {
84+ Self
85+ }
86+ }
87+ )
88+ }
Original file line number Diff line number Diff line change 1+ // aux-build:proc_macro_derive.rs
2+
13#![ allow(
24 unused,
35 dead_code,
79) ]
810#![ warn( clippy:: extra_unused_lifetimes) ]
911
12+ #[ macro_use]
13+ extern crate proc_macro_derive;
14+
1015fn empty ( ) { }
1116
1217fn used_lt < ' a > ( x : & ' a u8 ) { }
@@ -114,4 +119,11 @@ mod second_case {
114119 }
115120}
116121
122+ // Should not lint
123+ #[ derive( ExtraLifetimeDerive ) ]
124+ struct Human < ' a > {
125+ pub bones : i32 ,
126+ pub name : & ' a str ,
127+ }
128+
117129fn main ( ) { }
Original file line number Diff line number Diff line change 11error: this lifetime isn't used in the function definition
2- --> $DIR/extra_unused_lifetimes.rs:14 :14
2+ --> $DIR/extra_unused_lifetimes.rs:19 :14
33 |
44LL | fn unused_lt<'a>(x: u8) {}
55 | ^^
66 |
77 = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings`
88
99error: this lifetime isn't used in the function definition
10- --> $DIR/extra_unused_lifetimes.rs:41 :10
10+ --> $DIR/extra_unused_lifetimes.rs:46 :10
1111 |
1212LL | fn x<'a>(&self) {}
1313 | ^^
1414
1515error: this lifetime isn't used in the function definition
16- --> $DIR/extra_unused_lifetimes.rs:67 :22
16+ --> $DIR/extra_unused_lifetimes.rs:72 :22
1717 |
1818LL | fn unused_lt<'a>(x: u8) {}
1919 | ^^
2020
2121error: this lifetime isn't used in the impl
22- --> $DIR/extra_unused_lifetimes.rs:78 :10
22+ --> $DIR/extra_unused_lifetimes.rs:83 :10
2323 |
2424LL | impl<'a> std::ops::AddAssign<&Scalar> for &mut Scalar {
2525 | ^^
2626
2727error: this lifetime isn't used in the impl
28- --> $DIR/extra_unused_lifetimes.rs:84 :10
28+ --> $DIR/extra_unused_lifetimes.rs:89 :10
2929 |
3030LL | impl<'b> Scalar {
3131 | ^^
3232
3333error: this lifetime isn't used in the function definition
34- --> $DIR/extra_unused_lifetimes.rs:85 :26
34+ --> $DIR/extra_unused_lifetimes.rs:90 :26
3535 |
3636LL | pub fn something<'c>() -> Self {
3737 | ^^
You can’t perform that action at this time.
0 commit comments