Skip to content

Commit 666859a

Browse files
committed
Make late and late_anon regions track the bound var position
1 parent 84f82d3 commit 666859a

File tree

6 files changed

+99
-54
lines changed

6 files changed

+99
-54
lines changed

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
115115
// error. We will then search the function parameters for a bound
116116
// region at the right depth with the same index
117117
(
118-
Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)),
118+
Some(rl::Region::LateBoundAnon(debruijn_index, _, anon_index)),
119119
ty::BrAnon(br_index),
120120
) => {
121121
debug!(
@@ -143,7 +143,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
143143
// error. We will then search the function parameters for a bound
144144
// region at the right depth with the same index
145145
(
146-
Some(rl::Region::LateBound(debruijn_index, id, _)),
146+
Some(rl::Region::LateBound(debruijn_index, _, id, _)),
147147
ty::BrNamed(def_id, _),
148148
) => {
149149
debug!(
@@ -162,8 +162,8 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
162162
rl::Region::Static
163163
| rl::Region::Free(_, _)
164164
| rl::Region::EarlyBound(_, _, _)
165-
| rl::Region::LateBound(_, _, _)
166-
| rl::Region::LateBoundAnon(_, _),
165+
| rl::Region::LateBound(_, _, _, _)
166+
| rl::Region::LateBoundAnon(_, _, _),
167167
)
168168
| None,
169169
_,
@@ -217,7 +217,10 @@ impl Visitor<'tcx> for TyPathVisitor<'tcx> {
217217
fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
218218
match (self.tcx.named_region(lifetime.hir_id), self.bound_region) {
219219
// the lifetime of the TyPath!
220-
(Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)), ty::BrAnon(br_index)) => {
220+
(
221+
Some(rl::Region::LateBoundAnon(debruijn_index, _, anon_index)),
222+
ty::BrAnon(br_index),
223+
) => {
221224
if debruijn_index == self.current_index && anon_index == br_index {
222225
self.found_it = true;
223226
return;
@@ -232,7 +235,7 @@ impl Visitor<'tcx> for TyPathVisitor<'tcx> {
232235
}
233236
}
234237

235-
(Some(rl::Region::LateBound(debruijn_index, id, _)), ty::BrNamed(def_id, _)) => {
238+
(Some(rl::Region::LateBound(debruijn_index, _, id, _)), ty::BrNamed(def_id, _)) => {
236239
debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}", debruijn_index,);
237240
debug!("id={:?}", id);
238241
debug!("def_id={:?}", def_id);
@@ -246,8 +249,8 @@ impl Visitor<'tcx> for TyPathVisitor<'tcx> {
246249
Some(
247250
rl::Region::Static
248251
| rl::Region::EarlyBound(_, _, _)
249-
| rl::Region::LateBound(_, _, _)
250-
| rl::Region::LateBoundAnon(_, _)
252+
| rl::Region::LateBound(_, _, _, _)
253+
| rl::Region::LateBoundAnon(_, _, _)
251254
| rl::Region::Free(_, _),
252255
)
253256
| None,

compiler/rustc_middle/src/middle/resolve_lifetime.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ impl LifetimeDefOrigin {
3939
pub enum Region {
4040
Static,
4141
EarlyBound(/* index */ u32, /* lifetime decl */ DefId, LifetimeDefOrigin),
42-
LateBound(ty::DebruijnIndex, /* lifetime decl */ DefId, LifetimeDefOrigin),
43-
LateBoundAnon(ty::DebruijnIndex, /* anon index */ u32),
42+
LateBound(
43+
ty::DebruijnIndex,
44+
/* late-bound index */ u32,
45+
/* lifetime decl */ DefId,
46+
LifetimeDefOrigin,
47+
),
48+
LateBoundAnon(ty::DebruijnIndex, /* late-bound index */ u32, /* anon index */ u32),
4449
Free(DefId, /* lifetime decl */ DefId),
4550
}
4651

0 commit comments

Comments
 (0)