Skip to content

Commit 421bb6a

Browse files
committed
Remove index from Region::EarlyBound.
1 parent 63c3aab commit 421bb6a

File tree

6 files changed

+50
-214
lines changed

6 files changed

+50
-214
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
103103
// Find the index of the named region that was part of the
104104
// error. We will then search the function parameters for a bound
105105
// region at the right depth with the same index
106-
(Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
106+
(Some(rl::Region::EarlyBound(id)), ty::BrNamed(def_id, _)) => {
107107
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
108108
if id == def_id {
109109
self.found_type = Some(arg);
@@ -133,7 +133,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
133133
Some(
134134
rl::Region::Static
135135
| rl::Region::Free(_, _)
136-
| rl::Region::EarlyBound(_, _)
136+
| rl::Region::EarlyBound(_)
137137
| rl::Region::LateBound(_, _, _),
138138
)
139139
| None,
@@ -188,7 +188,7 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'tcx> {
188188
fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
189189
match (self.tcx.named_region(lifetime.hir_id), self.bound_region) {
190190
// the lifetime of the TyPath!
191-
(Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
191+
(Some(rl::Region::EarlyBound(id)), ty::BrNamed(def_id, _)) => {
192192
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
193193
if id == def_id {
194194
self.found_it = true;
@@ -209,7 +209,7 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'tcx> {
209209
(
210210
Some(
211211
rl::Region::Static
212-
| rl::Region::EarlyBound(_, _)
212+
| rl::Region::EarlyBound(_)
213213
| rl::Region::LateBound(_, _, _)
214214
| rl::Region::Free(_, _),
215215
)

compiler/rustc_lint/src/builtin.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,13 +2039,13 @@ declare_lint_pass!(ExplicitOutlivesRequirements => [EXPLICIT_OUTLIVES_REQUIREMEN
20392039
impl ExplicitOutlivesRequirements {
20402040
fn lifetimes_outliving_lifetime<'tcx>(
20412041
inferred_outlives: &'tcx [(ty::Predicate<'tcx>, Span)],
2042-
index: u32,
2042+
def_id: DefId,
20432043
) -> Vec<ty::Region<'tcx>> {
20442044
inferred_outlives
20452045
.iter()
20462046
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
20472047
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match *a {
2048-
ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
2048+
ty::ReEarlyBound(ebr) if ebr.def_id == def_id => Some(b),
20492049
_ => None,
20502050
},
20512051
_ => None,
@@ -2082,8 +2082,12 @@ impl ExplicitOutlivesRequirements {
20822082
.filter_map(|(i, bound)| {
20832083
if let hir::GenericBound::Outlives(lifetime) = bound {
20842084
let is_inferred = match tcx.named_region(lifetime.hir_id) {
2085-
Some(Region::EarlyBound(index, ..)) => inferred_outlives.iter().any(|r| {
2086-
if let ty::ReEarlyBound(ebr) = **r { ebr.index == index } else { false }
2085+
Some(Region::EarlyBound(def_id)) => inferred_outlives.iter().any(|r| {
2086+
if let ty::ReEarlyBound(ebr) = **r {
2087+
ebr.def_id == def_id
2088+
} else {
2089+
false
2090+
}
20872091
}),
20882092
_ => false,
20892093
};
@@ -2177,11 +2181,14 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
21772181
for (i, where_predicate) in hir_generics.predicates.iter().enumerate() {
21782182
let (relevant_lifetimes, bounds, span, in_where_clause) = match where_predicate {
21792183
hir::WherePredicate::RegionPredicate(predicate) => {
2180-
if let Some(Region::EarlyBound(index, ..)) =
2184+
if let Some(Region::EarlyBound(region_def_id)) =
21812185
cx.tcx.named_region(predicate.lifetime.hir_id)
21822186
{
21832187
(
2184-
Self::lifetimes_outliving_lifetime(inferred_outlives, index),
2188+
Self::lifetimes_outliving_lifetime(
2189+
inferred_outlives,
2190+
region_def_id,
2191+
),
21852192
&predicate.bounds,
21862193
predicate.span,
21872194
predicate.in_where_clause,

compiler/rustc_middle/src/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_macros::HashStable;
1010
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, HashStable)]
1111
pub enum Region {
1212
Static,
13-
EarlyBound(/* index */ u32, /* lifetime decl */ DefId),
13+
EarlyBound(/* lifetime decl */ DefId),
1414
LateBound(ty::DebruijnIndex, /* late-bound index */ u32, /* lifetime decl */ DefId),
1515
Free(DefId, /* lifetime decl */ DefId),
1616
}

0 commit comments

Comments
 (0)