Fix lifetime tests
This commit is contained in:
parent
0a11c5c49a
commit
f2495a1777
@ -9,7 +9,7 @@ struct Baz<'a> {
|
||||
bar: &'a Bar,
|
||||
}
|
||||
|
||||
impl<'a> Foo for Baz<'a> {}
|
||||
impl Foo for Baz<'_> {}
|
||||
|
||||
impl Bar {
|
||||
fn baz(&self) -> impl Foo + '_ {
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> tests/ui/crashes/needless_lifetimes_impl_trait.rs:15:12
|
||||
--> tests/ui/crashes/needless_lifetimes_impl_trait.rs:12:6
|
||||
|
|
||||
LL | fn baz<'a>(&'a self) -> impl Foo + 'a {
|
||||
| ^^ ^^ ^^
|
||||
LL | impl<'a> Foo for Baz<'a> {}
|
||||
| ^^ ^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> tests/ui/crashes/needless_lifetimes_impl_trait.rs:1:9
|
||||
@ -11,9 +11,21 @@ LL | #![deny(clippy::needless_lifetimes)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: elide the lifetimes
|
||||
|
|
||||
LL - impl<'a> Foo for Baz<'a> {}
|
||||
LL + impl Foo for Baz<'_> {}
|
||||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> tests/ui/crashes/needless_lifetimes_impl_trait.rs:15:12
|
||||
|
|
||||
LL | fn baz<'a>(&'a self) -> impl Foo + 'a {
|
||||
| ^^ ^^ ^^
|
||||
|
|
||||
help: elide the lifetimes
|
||||
|
|
||||
LL - fn baz<'a>(&'a self) -> impl Foo + 'a {
|
||||
LL + fn baz(&self) -> impl Foo + '_ {
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -114,9 +114,17 @@ pub trait Source {
|
||||
fn hey();
|
||||
}
|
||||
|
||||
// Should lint. The response to the above comment incorrectly called this a false positive. The
|
||||
// lifetime `'a` can be removed, as demonstrated below.
|
||||
impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
|
||||
fn hey() {}
|
||||
}
|
||||
|
||||
struct OtherBox<T: ?Sized>(Box<T>);
|
||||
|
||||
impl<T: Source + ?Sized> Source for OtherBox<T> {
|
||||
fn hey() {}
|
||||
}
|
||||
}
|
||||
|
||||
// Should not lint
|
||||
|
@ -37,5 +37,11 @@ error: this lifetime isn't used in the function definition
|
||||
LL | pub fn something<'c>() -> Self {
|
||||
| ^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: this lifetime isn't used in the impl
|
||||
--> tests/ui/extra_unused_lifetimes.rs:119:10
|
||||
|
|
||||
LL | impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
|
||||
| ^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
@ -329,7 +329,7 @@ mod issue2944 {
|
||||
bar: &'a Bar,
|
||||
}
|
||||
|
||||
impl<'a> Foo for Baz<'a> {}
|
||||
impl Foo for Baz<'_> {}
|
||||
impl Bar {
|
||||
fn baz(&self) -> impl Foo + '_ {
|
||||
Baz { bar: self }
|
||||
|
@ -335,6 +335,18 @@ LL - fn needless_lt<'a>(_x: &'a u8) {}
|
||||
LL + fn needless_lt(_x: &u8) {}
|
||||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> tests/ui/needless_lifetimes.rs:332:10
|
||||
|
|
||||
LL | impl<'a> Foo for Baz<'a> {}
|
||||
| ^^ ^^
|
||||
|
|
||||
help: elide the lifetimes
|
||||
|
|
||||
LL - impl<'a> Foo for Baz<'a> {}
|
||||
LL + impl Foo for Baz<'_> {}
|
||||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> tests/ui/needless_lifetimes.rs:334:16
|
||||
|
|
||||
@ -564,5 +576,5 @@ LL - fn one_input<'a>(x: &'a u8) -> &'a u8 {
|
||||
LL + fn one_input(x: &u8) -> &u8 {
|
||||
|
|
||||
|
||||
error: aborting due to 47 previous errors
|
||||
error: aborting due to 48 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user