Skip to content

Commit d3c2386

Browse files
committed
extend E0623 for earlybound and latebound for structs
1 parent d1ca653 commit d3c2386

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

src/librustc/infer/error_reporting/different_lifetimes.rs

+33-11
Original file line numberDiff line numberDiff line change
@@ -321,24 +321,46 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
321321
}
322322

323323
fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
324-
let br_index = match self.bound_region {
325-
ty::BrAnon(index) => index,
326-
_ => return,
327-
};
328324

329325
let hir_id = self.infcx.tcx.hir.node_to_hir_id(lifetime.id);
330-
match self.infcx.tcx.named_region(hir_id) {
326+
match (self.infcx.tcx.named_region(hir_id), self.bound_region) {
331327
// the lifetime of the TyPath!
332-
Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)) => {
328+
(Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)), ty::BrAnon(br_index)) => {
333329
if debruijn_index.depth == 1 && anon_index == br_index {
334330
self.found_it = true;
331+
return;
332+
}
333+
}
334+
335+
(Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
336+
debug!("EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \
337+
def_id={:?}",
338+
self.infcx.tcx.hir.local_def_id(id),
339+
def_id);
340+
if self.infcx.tcx.hir.local_def_id(id) == def_id {
341+
self.found_it = true;
342+
return; // we can stop visiting now
335343
}
336344
}
337-
Some(rl::Region::Static) |
338-
Some(rl::Region::EarlyBound(_, _)) |
339-
Some(rl::Region::LateBound(_, _)) |
340-
Some(rl::Region::Free(_, _)) |
341-
None => {
345+
346+
(Some(rl::Region::LateBound(debruijn_index, id)), ty::BrNamed(def_id, _)) => {
347+
debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
348+
debruijn_index.depth);
349+
debug!("self.infcx.tcx.hir.local_def_id(id)={:?}",
350+
self.infcx.tcx.hir.local_def_id(id));
351+
debug!("def_id={:?}", def_id);
352+
if debruijn_index.depth == 1 && self.infcx.tcx.hir.local_def_id(id) == def_id {
353+
self.found_it = true;
354+
return; // we can stop visiting now
355+
}
356+
}
357+
358+
(Some(rl::Region::Static), _) |
359+
(Some(rl::Region::EarlyBound(_, _)), _) |
360+
(Some(rl::Region::LateBound(_, _)), _) |
361+
(Some(rl::Region::LateBoundAnon(_, _)), _) |
362+
(Some(rl::Region::Free(_, _)), _) |
363+
(None, _) => {
342364
debug!("no arg found");
343365
}
344366
}

0 commit comments

Comments
 (0)