support impl trait for needless lifetimes
This commit is contained in:
parent
cb861a1bd1
commit
93333f0d7b
@ -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 New Issue
Block a user