output_visitor.visit_ty(ty);
}
- let input_lts = lts_from_bounds(input_visitor.into_vec(), bounds_lts);
- let output_lts = output_visitor.into_vec();
+ let input_lts = match input_visitor.into_vec() {
+ Some(lts) => lts_from_bounds(lts, bounds_lts),
+ None => return false,
+ };
+ let output_lts = match output_visitor.into_vec() {
+ Some(val) => val,
+ None => return false,
+ };
if let Some(body_id) = body {
let mut checker = BodyLifetimeChecker { lifetimes_used_in_body: false };
struct RefVisitor<'a, 'tcx: 'a> {
cx: &'a LateContext<'a, 'tcx>,
lts: Vec<RefLt>,
+ abort: bool,
}
impl<'v, 't> RefVisitor<'v, 't> {
RefVisitor {
cx: cx,
lts: Vec::new(),
+ abort: false,
}
}
}
}
- fn into_vec(self) -> Vec<RefLt> {
- self.lts
+ fn into_vec(self) -> Option<Vec<RefLt>> {
+ if self.abort {
+ None
+ } else {
+ Some(self.lts)
+ }
}
fn collect_anonymous_lifetimes(&mut self, qpath: &QPath, ty: &Ty) {
},
TyTraitObject(ref bounds, ref lt) => {
if !lt.is_elided() {
- self.record(&Some(*lt));
+ self.abort = true;
}
for bound in bounds {
self.visit_poly_trait_ref(bound, TraitBoundModifier::None);
walk_ty_param_bound(&mut visitor, bound);
}
// and check that all lifetimes are allowed
- for lt in visitor.into_vec() {
- if !allowed_lts.contains(<) {
- return true;
- }
+ match visitor.into_vec() {
+ None => return false,
+ Some(lts) => for lt in lts {
+ if !allowed_lts.contains(<) {
+ return true;
+ }
+ },
}
},
WherePredicate::EqPredicate(ref pred) => {
132 | fn trait_bound_bug<'a, T: WithLifetime<'a>>() { unimplemented!() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: explicit lifetimes given in parameter types where they could be elided
- --> $DIR/lifetimes.rs:140:5
- |
-140 | fn iter<'a>(&'a self) -> Box<Iterator<Item = usize> + 'a> {
- | _____^ starting here...
-141 | | unimplemented!()
-142 | | }
- | |_____^ ...ending here
-
warning: unused variable: `cx`
--> $DIR/lifetimes.rs:148:30
|
|
= note: #[warn(unused_variables)] on by default
-error: aborting due to 16 previous errors
+error: aborting due to 15 previous errors