mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Merge pull request #1400 from oli-obk/needed_needless_lifetime
support impl trait for needless lifetimes
This commit is contained in:
commit
96d2483b09
2 changed files with 29 additions and 0 deletions
|
@ -281,6 +281,13 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
|
|||
TyPath(ref path) => {
|
||||
self.collect_anonymous_lifetimes(path, ty);
|
||||
},
|
||||
TyImplTrait(ref param_bounds) => {
|
||||
for bound in param_bounds {
|
||||
if let RegionTyParamBound(_) = *bound {
|
||||
self.record(&None);
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
walk_ty(self, ty);
|
||||
|
|
22
tests/run-pass/needless_lifetimes_impl_trait.rs
Normal file
22
tests/run-pass/needless_lifetimes_impl_trait.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
#![feature(conservative_impl_trait)]
|
||||
#![deny(needless_lifetime)]
|
||||
|
||||
trait Foo {}
|
||||
|
||||
struct Bar {}
|
||||
|
||||
struct Baz<'a> {
|
||||
bar: &'a Bar,
|
||||
}
|
||||
|
||||
impl<'a> Foo for Baz<'a> {}
|
||||
|
||||
impl Bar {
|
||||
fn baz<'a>(&'a self) -> impl Foo + 'a {
|
||||
Baz { bar: self }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in a new issue