support impl trait for needless lifetimes

This commit is contained in:
Oliver Schneider 2016-12-22 15:51:59 +01:00
parent cb861a1bd1
commit 93333f0d7b
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46
2 changed files with 29 additions and 0 deletions

View File

@ -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);

View 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() {}