File tree Expand file tree Collapse file tree 6 files changed +46
-8
lines changed Expand file tree Collapse file tree 6 files changed +46
-8
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ struct Baz<'a> {
9
9
bar: &'a Bar,
10
10
}
11
11
12
- impl<'a> Foo for Baz<'a > {}
12
+ impl Foo for Baz<'_ > {}
13
13
14
14
impl Bar {
15
15
fn baz(&self) -> impl Foo + '_ {
Original file line number Diff line number Diff line change 1
1
error: the following explicit lifetimes could be elided: 'a
2
- --> tests/ui/crashes/needless_lifetimes_impl_trait.rs:15:12
2
+ --> tests/ui/crashes/needless_lifetimes_impl_trait.rs:12:6
3
3
|
4
- LL | fn baz <'a>(&'a self) -> impl Foo + 'a {
5
- | ^^ ^^ ^^
4
+ LL | impl <'a> Foo for Baz<'a> {}
5
+ | ^^ ^^
6
6
|
7
7
note: the lint level is defined here
8
8
--> tests/ui/crashes/needless_lifetimes_impl_trait.rs:1:9
@@ -11,9 +11,21 @@ LL | #![deny(clippy::needless_lifetimes)]
11
11
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
12
12
help: elide the lifetimes
13
13
|
14
+ LL - impl<'a> Foo for Baz<'a> {}
15
+ LL + impl Foo for Baz<'_> {}
16
+ |
17
+
18
+ error: the following explicit lifetimes could be elided: 'a
19
+ --> tests/ui/crashes/needless_lifetimes_impl_trait.rs:15:12
20
+ |
21
+ LL | fn baz<'a>(&'a self) -> impl Foo + 'a {
22
+ | ^^ ^^ ^^
23
+ |
24
+ help: elide the lifetimes
25
+ |
14
26
LL - fn baz<'a>(&'a self) -> impl Foo + 'a {
15
27
LL + fn baz(&self) -> impl Foo + '_ {
16
28
|
17
29
18
- error: aborting due to 1 previous error
30
+ error: aborting due to 2 previous errors
19
31
Original file line number Diff line number Diff line change @@ -114,9 +114,17 @@ mod second_case {
114
114
fn hey ( ) ;
115
115
}
116
116
117
+ // Should lint. The response to the above comment incorrectly called this a false positive. The
118
+ // lifetime `'a` can be removed, as demonstrated below.
117
119
impl < ' a , T : Source + ?Sized + ' a > Source for Box < T > {
118
120
fn hey ( ) { }
119
121
}
122
+
123
+ struct OtherBox < T : ?Sized > ( Box < T > ) ;
124
+
125
+ impl < T : Source + ?Sized > Source for OtherBox < T > {
126
+ fn hey ( ) { }
127
+ }
120
128
}
121
129
122
130
// Should not lint
Original file line number Diff line number Diff line change @@ -37,5 +37,11 @@ error: this lifetime isn't used in the function definition
37
37
LL | pub fn something<'c>() -> Self {
38
38
| ^^
39
39
40
- error: aborting due to 6 previous errors
40
+ error: this lifetime isn't used in the impl
41
+ --> tests/ui/extra_unused_lifetimes.rs:119:10
42
+ |
43
+ LL | impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
44
+ | ^^
45
+
46
+ error: aborting due to 7 previous errors
41
47
Original file line number Diff line number Diff line change @@ -329,7 +329,7 @@ mod issue2944 {
329
329
bar: &'a Bar,
330
330
}
331
331
332
- impl<'a> Foo for Baz<'a > {}
332
+ impl Foo for Baz<'_ > {}
333
333
impl Bar {
334
334
fn baz(&self) -> impl Foo + '_ {
335
335
Baz { bar: self }
Original file line number Diff line number Diff line change @@ -335,6 +335,18 @@ LL - fn needless_lt<'a>(_x: &'a u8) {}
335
335
LL + fn needless_lt(_x: &u8) {}
336
336
|
337
337
338
+ error: the following explicit lifetimes could be elided: 'a
339
+ --> tests/ui/needless_lifetimes.rs:332:10
340
+ |
341
+ LL | impl<'a> Foo for Baz<'a> {}
342
+ | ^^ ^^
343
+ |
344
+ help: elide the lifetimes
345
+ |
346
+ LL - impl<'a> Foo for Baz<'a> {}
347
+ LL + impl Foo for Baz<'_> {}
348
+ |
349
+
338
350
error: the following explicit lifetimes could be elided: 'a
339
351
--> tests/ui/needless_lifetimes.rs:334:16
340
352
|
@@ -564,5 +576,5 @@ LL - fn one_input<'a>(x: &'a u8) -> &'a u8 {
564
576
LL + fn one_input(x: &u8) -> &u8 {
565
577
|
566
578
567
- error: aborting due to 47 previous errors
579
+ error: aborting due to 48 previous errors
568
580
You can’t perform that action at this time.
0 commit comments