You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cargo clippy
warning: explicit lifetimes given in parameter types where they could be elided, #[warn(needless_lifetimes)] on by default
--> src/main.rs:14:5
|
14 | fn baz<'a>(&'a self) -> impl Foo + 'a {
| ^
|
= help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#needless_lifetimes
If you apply the suggestion:
impl<'a> Foo for Baz<'a> {}
impl Bar {
- fn baz<'a>(&'a self) -> impl Foo + 'a {+ fn baz(&self) -> impl Foo {
Baz { bar: self }
}
}
you end with code that doesn't compile:
$ cargo clippy
error[E0564]: only named lifetimes are allowed in `impl Trait`, but `` was found in the type `Baz<'_>`
--> src/main.rs:14:22
|
14 | fn baz(&self) -> impl Foo {
| ^^^^^^^^
error: aborting due to previous error
I don't know if these lifetimes will become elidable in the future but, in this case, clippy should probably not raise a warning for now.
The text was updated successfully, but these errors were encountered:
This code compiles:
But clippy gives this warning:
If you apply the suggestion:
you end with code that doesn't compile:
I don't know if these lifetimes will become elidable in the future but, in this case, clippy should probably not raise a warning for now.
The text was updated successfully, but these errors were encountered: