Skip to content

Commit bc70bb9

Browse files
committed
Remove index from Region::EarlyBound.
1 parent a959cf6 commit bc70bb9

File tree

6 files changed

+45
-162
lines changed

6 files changed

+45
-162
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
@@ -120,7 +120,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
120120
// Find the index of the named region that was part of the
121121
// error. We will then search the function parameters for a bound
122122
// region at the right depth with the same index
123-
(Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
123+
(Some(rl::Region::EarlyBound(id)), ty::BrNamed(def_id, _)) => {
124124
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
125125
if id == def_id {
126126
self.found_type = Some(arg);
@@ -150,7 +150,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
150150
Some(
151151
rl::Region::Static
152152
| rl::Region::Free(_, _)
153-
| rl::Region::EarlyBound(_, _)
153+
| rl::Region::EarlyBound(_)
154154
| rl::Region::LateBound(_, _, _)
155155
| rl::Region::LateBoundAnon(_, _, _),
156156
)
@@ -216,7 +216,7 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'tcx> {
216216
}
217217
}
218218

219-
(Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
219+
(Some(rl::Region::EarlyBound(id)), ty::BrNamed(def_id, _)) => {
220220
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
221221
if id == def_id {
222222
self.found_it = true;
@@ -237,7 +237,7 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'tcx> {
237237
(
238238
Some(
239239
rl::Region::Static
240-
| rl::Region::EarlyBound(_, _)
240+
| rl::Region::EarlyBound(_)
241241
| rl::Region::LateBound(_, _, _)
242242
| rl::Region::LateBoundAnon(_, _, _)
243243
| rl::Region::Free(_, _),

compiler/rustc_lint/src/builtin.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,13 +2050,13 @@ declare_lint_pass!(ExplicitOutlivesRequirements => [EXPLICIT_OUTLIVES_REQUIREMEN
20502050
impl ExplicitOutlivesRequirements {
20512051
fn lifetimes_outliving_lifetime<'tcx>(
20522052
inferred_outlives: &'tcx [(ty::Predicate<'tcx>, Span)],
2053-
index: u32,
2053+
def_id: DefId,
20542054
) -> Vec<ty::Region<'tcx>> {
20552055
inferred_outlives
20562056
.iter()
20572057
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
20582058
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match *a {
2059-
ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
2059+
ty::ReEarlyBound(ebr) if ebr.def_id == def_id => Some(b),
20602060
_ => None,
20612061
},
20622062
_ => None,
@@ -2097,8 +2097,12 @@ impl ExplicitOutlivesRequirements {
20972097
Some(Region::Static) if infer_static => {
20982098
inferred_outlives.iter().any(|r| matches!(**r, ty::ReStatic))
20992099
}
2100-
Some(Region::EarlyBound(index, ..)) => inferred_outlives.iter().any(|r| {
2101-
if let ty::ReEarlyBound(ebr) = **r { ebr.index == index } else { false }
2100+
Some(Region::EarlyBound(def_id)) => inferred_outlives.iter().any(|r| {
2101+
if let ty::ReEarlyBound(ebr) = **r {
2102+
ebr.def_id == def_id
2103+
} else {
2104+
false
2105+
}
21022106
}),
21032107
_ => false,
21042108
};
@@ -2193,11 +2197,14 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
21932197
for (i, where_predicate) in hir_generics.predicates.iter().enumerate() {
21942198
let (relevant_lifetimes, bounds, span, in_where_clause) = match where_predicate {
21952199
hir::WherePredicate::RegionPredicate(predicate) => {
2196-
if let Some(Region::EarlyBound(index, ..)) =
2200+
if let Some(Region::EarlyBound(region_def_id)) =
21972201
cx.tcx.named_region(predicate.lifetime.hir_id)
21982202
{
21992203
(
2200-
Self::lifetimes_outliving_lifetime(inferred_outlives, index),
2204+
Self::lifetimes_outliving_lifetime(
2205+
inferred_outlives,
2206+
region_def_id,
2207+
),
22012208
&predicate.bounds,
22022209
predicate.span,
22032210
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
LateBoundAnon(ty::DebruijnIndex, /* late-bound index */ u32, /* anon index */ u32),
1616
Free(DefId, /* lifetime decl */ DefId),

0 commit comments

Comments
 (0)