File tree 3 files changed +32
-6
lines changed
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 {
72
72
}
73
73
)
74
74
}
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
+
1
3
#![ allow(
2
4
unused,
3
5
dead_code,
7
9
) ]
8
10
#![ warn( clippy:: extra_unused_lifetimes) ]
9
11
12
+ #[ macro_use]
13
+ extern crate proc_macro_derive;
14
+
10
15
fn empty ( ) { }
11
16
12
17
fn used_lt < ' a > ( x : & ' a u8 ) { }
@@ -114,4 +119,11 @@ mod second_case {
114
119
}
115
120
}
116
121
122
+ // Should not lint
123
+ #[ derive( ExtraLifetimeDerive ) ]
124
+ struct Human < ' a > {
125
+ pub bones : i32 ,
126
+ pub name : & ' a str ,
127
+ }
128
+
117
129
fn main ( ) { }
Original file line number Diff line number Diff line change 1
1
error: 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
3
3
|
4
4
LL | fn unused_lt<'a>(x: u8) {}
5
5
| ^^
6
6
|
7
7
= note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings`
8
8
9
9
error: 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
11
11
|
12
12
LL | fn x<'a>(&self) {}
13
13
| ^^
14
14
15
15
error: 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
17
17
|
18
18
LL | fn unused_lt<'a>(x: u8) {}
19
19
| ^^
20
20
21
21
error: this lifetime isn't used in the impl
22
- --> $DIR/extra_unused_lifetimes.rs:78 :10
22
+ --> $DIR/extra_unused_lifetimes.rs:83 :10
23
23
|
24
24
LL | impl<'a> std::ops::AddAssign<&Scalar> for &mut Scalar {
25
25
| ^^
26
26
27
27
error: this lifetime isn't used in the impl
28
- --> $DIR/extra_unused_lifetimes.rs:84 :10
28
+ --> $DIR/extra_unused_lifetimes.rs:89 :10
29
29
|
30
30
LL | impl<'b> Scalar {
31
31
| ^^
32
32
33
33
error: 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
35
35
|
36
36
LL | pub fn something<'c>() -> Self {
37
37
| ^^
You can’t perform that action at this time.
0 commit comments