Skip to content

Commit e7e5feb

Browse files
committed
In ReverseMapper, don't fallback to ReEmpty, instead ReStatic
1 parent f29c91b commit e7e5feb

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ struct ReverseMapper<'tcx> {
433433

434434
key: ty::OpaqueTypeKey<'tcx>,
435435
map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
436-
map_missing_regions_to_empty: bool,
436+
do_not_error: bool,
437437

438438
/// initially `Some`, set to `None` once error has been reported
439439
hidden_ty: Option<Ty<'tcx>>,
@@ -450,29 +450,19 @@ impl<'tcx> ReverseMapper<'tcx> {
450450
hidden_ty: Ty<'tcx>,
451451
span: Span,
452452
) -> Self {
453-
Self {
454-
tcx,
455-
key,
456-
map,
457-
map_missing_regions_to_empty: false,
458-
hidden_ty: Some(hidden_ty),
459-
span,
460-
}
453+
Self { tcx, key, map, do_not_error: false, hidden_ty: Some(hidden_ty), span }
461454
}
462455

463-
fn fold_kind_mapping_missing_regions_to_empty(
464-
&mut self,
465-
kind: GenericArg<'tcx>,
466-
) -> GenericArg<'tcx> {
467-
assert!(!self.map_missing_regions_to_empty);
468-
self.map_missing_regions_to_empty = true;
456+
fn fold_kind_no_missing_regions_error(&mut self, kind: GenericArg<'tcx>) -> GenericArg<'tcx> {
457+
assert!(!self.do_not_error);
458+
self.do_not_error = true;
469459
let kind = kind.fold_with(self);
470-
self.map_missing_regions_to_empty = false;
460+
self.do_not_error = false;
471461
kind
472462
}
473463

474464
fn fold_kind_normally(&mut self, kind: GenericArg<'tcx>) -> GenericArg<'tcx> {
475-
assert!(!self.map_missing_regions_to_empty);
465+
assert!(!self.do_not_error);
476466
kind.fold_with(self)
477467
}
478468
}
@@ -510,7 +500,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
510500
match self.map.get(&r.into()).map(|k| k.unpack()) {
511501
Some(GenericArgKind::Lifetime(r1)) => r1,
512502
Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
513-
None if self.map_missing_regions_to_empty => self.tcx.lifetimes.re_root_empty,
503+
None if self.do_not_error => self.tcx.lifetimes.re_static,
514504
None if generics.parent.is_some() => {
515505
if let Some(hidden_ty) = self.hidden_ty.take() {
516506
unexpected_hidden_region_diagnostic(
@@ -522,7 +512,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
522512
)
523513
.emit();
524514
}
525-
self.tcx.lifetimes.re_root_empty
515+
self.tcx.lifetimes.re_static
526516
}
527517
None => {
528518
self.tcx
@@ -574,7 +564,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
574564
let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
575565
if index < generics.parent_count {
576566
// Accommodate missing regions in the parent kinds...
577-
self.fold_kind_mapping_missing_regions_to_empty(kind)
567+
self.fold_kind_no_missing_regions_error(kind)
578568
} else {
579569
// ...but not elsewhere.
580570
self.fold_kind_normally(kind)
@@ -589,7 +579,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
589579
let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
590580
if index < generics.parent_count {
591581
// Accommodate missing regions in the parent kinds...
592-
self.fold_kind_mapping_missing_regions_to_empty(kind)
582+
self.fold_kind_no_missing_regions_error(kind)
593583
} else {
594584
// ...but not elsewhere.
595585
self.fold_kind_normally(kind)

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ pub struct CommonTypes<'tcx> {
276276
}
277277

278278
pub struct CommonLifetimes<'tcx> {
279-
/// `ReEmpty` in the root universe.
280-
pub re_root_empty: Region<'tcx>,
281-
282279
/// `ReStatic`
283280
pub re_static: Region<'tcx>,
284281

@@ -987,11 +984,7 @@ impl<'tcx> CommonLifetimes<'tcx> {
987984
))
988985
};
989986

990-
CommonLifetimes {
991-
re_root_empty: mk(ty::ReEmpty(ty::UniverseIndex::ROOT)),
992-
re_static: mk(ty::ReStatic),
993-
re_erased: mk(ty::ReErased),
994-
}
987+
CommonLifetimes { re_static: mk(ty::ReStatic), re_erased: mk(ty::ReErased) }
995988
}
996989
}
997990

0 commit comments

Comments
 (0)