diff --git a/.travis.yml b/.travis.yml index bd997a0c22e..7eaa61c5572 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,3 +5,4 @@ sudo: false script: - python util/update_lints.py -c - cargo test + - bash util/dogfood.sh diff --git a/src/lifetimes.rs b/src/lifetimes.rs index c333f04ab44..c3c915ea777 100644 --- a/src/lifetimes.rs +++ b/src/lifetimes.rs @@ -170,15 +170,15 @@ impl RefVisitor { impl<'v> Visitor<'v> for RefVisitor { // for lifetimes of references - fn visit_opt_lifetime_ref(&mut self, _: Span, lifetime: &Option) { + fn visit_opt_lifetime_ref(&mut self, _: Span, lifetime: &'v Option) { self.record(lifetime); } // for lifetimes as parameters of generics - fn visit_lifetime_ref(&mut self, lifetime: &Lifetime) { + fn visit_lifetime_ref(&mut self, lifetime: &'v Lifetime) { self.record(&Some(*lifetime)); } // for lifetime bounds; the default impl calls visit_lifetime_ref - fn visit_lifetime_bound(&mut self, _: &Lifetime) { } + fn visit_lifetime_bound(&mut self, _: &'v Lifetime) { } } diff --git a/tests/compile-fail/lifetimes.rs b/tests/compile-fail/lifetimes.rs index 7f463ec70b4..287a8199d2c 100755 --- a/tests/compile-fail/lifetimes.rs +++ b/tests/compile-fail/lifetimes.rs @@ -2,7 +2,7 @@ #![plugin(clippy)] #![deny(needless_lifetimes)] - +#![allow(dead_code)] fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { } //~^ERROR explicit lifetimes given @@ -54,27 +54,13 @@ impl X { fn self_and_same_in<'s>(&'s self, _x: &'s u8) { } // no error, same lifetimes on two params } +struct Foo<'a>(&'a u8); + +impl<'a> Foo<'a> { + fn self_shared_lifetime(&self, _: &'a u8) {} // no error, lifetime 'a not defined in method + fn self_bound_lifetime<'b: 'a>(&self, _: &'b u8) {} // no error, bounds exist +} static STATIC: u8 = 1; fn main() { - distinct_lifetimes(&1, &2, 3); - distinct_and_static(&1, &2, &STATIC); - same_lifetime_on_input(&1, &2); - only_static_on_input(&1, &2, &STATIC); - in_and_out(&1, 2); - multiple_in_and_out_1(&1, &2); - multiple_in_and_out_2(&1, &2); - in_static_and_out(&1, &STATIC); - let _ = deep_reference_1(&1, &2); - let _ = deep_reference_2(Ok(&1)); - let _ = deep_reference_3(&1, 2); - lifetime_param_1(&1, &2); - lifetime_param_2(&1, &2); - lifetime_param_3(&1, &2); - - let foo = X { x: 1 }; - foo.self_and_out(); - foo.self_and_in_out(&1); - foo.distinct_self_and_in(&1); - foo.self_and_same_in(&1); } diff --git a/util/dogfood.sh b/util/dogfood.sh index 1fa091c9f39..51dd465a25d 100644 --- a/util/dogfood.sh +++ b/util/dogfood.sh @@ -1 +1,4 @@ -rm -rf target* && cargo build --lib && cp -R target target_recur && cargo rustc -- -Zextra-plugins=clippy -Ltarget_recur/debug -Dclippy \ No newline at end of file +rm -rf target*/*so +cargo build --lib && cp -R target target_recur && cargo rustc -- -Zextra-plugins=clippy -Ltarget_recur/debug -Dclippy || exit 1 +rm -rf target_recur +