Merge pull request #1400 from oli-obk/needed_needless_lifetime

support impl trait for needless lifetimes
This commit is contained in:
Martin Carton 2016-12-25 18:24:39 +01:00 committed by GitHub
commit 96d2483b09
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() {}