about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
diff options
context:
space:
mode:
authorJack Huey <31162821+jackh726@users.noreply.github.com>2022-06-26 12:01:05 -0400
committerJack Huey <31162821+jackh726@users.noreply.github.com>2022-09-08 17:57:34 -0400
commite7e5feb637ca0e130f2890800da054771410d321 (patch)
tree88756ded9b6a2fe8d347179f338380aa6f7dd608 /compiler/rustc_borrowck/src
parentf29c91bf1245fc01853b0f1d8913139b3b355f63 (diff)
downloadrust-e7e5feb637ca0e130f2890800da054771410d321.tar.gz
rust-e7e5feb637ca0e130f2890800da054771410d321.zip
In ReverseMapper, don't fallback to ReEmpty, instead ReStatic
Diffstat (limited to 'compiler/rustc_borrowck/src')
-rw-r--r--compiler/rustc_borrowck/src/region_infer/opaque_types.rs32
1 files changed, 11 insertions, 21 deletions
diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs
index 3e6a48195f8..0b8ed0fcf27 100644
--- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs
+++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs
@@ -433,7 +433,7 @@ struct ReverseMapper<'tcx> {
 
     key: ty::OpaqueTypeKey<'tcx>,
     map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
-    map_missing_regions_to_empty: bool,
+    do_not_error: bool,
 
     /// initially `Some`, set to `None` once error has been reported
     hidden_ty: Option<Ty<'tcx>>,
@@ -450,29 +450,19 @@ impl<'tcx> ReverseMapper<'tcx> {
         hidden_ty: Ty<'tcx>,
         span: Span,
     ) -> Self {
-        Self {
-            tcx,
-            key,
-            map,
-            map_missing_regions_to_empty: false,
-            hidden_ty: Some(hidden_ty),
-            span,
-        }
+        Self { tcx, key, map, do_not_error: false, hidden_ty: Some(hidden_ty), span }
     }
 
-    fn fold_kind_mapping_missing_regions_to_empty(
-        &mut self,
-        kind: GenericArg<'tcx>,
-    ) -> GenericArg<'tcx> {
-        assert!(!self.map_missing_regions_to_empty);
-        self.map_missing_regions_to_empty = true;
+    fn fold_kind_no_missing_regions_error(&mut self, kind: GenericArg<'tcx>) -> GenericArg<'tcx> {
+        assert!(!self.do_not_error);
+        self.do_not_error = true;
         let kind = kind.fold_with(self);
-        self.map_missing_regions_to_empty = false;
+        self.do_not_error = false;
         kind
     }
 
     fn fold_kind_normally(&mut self, kind: GenericArg<'tcx>) -> GenericArg<'tcx> {
-        assert!(!self.map_missing_regions_to_empty);
+        assert!(!self.do_not_error);
         kind.fold_with(self)
     }
 }
@@ -510,7 +500,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
         match self.map.get(&r.into()).map(|k| k.unpack()) {
             Some(GenericArgKind::Lifetime(r1)) => r1,
             Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
-            None if self.map_missing_regions_to_empty => self.tcx.lifetimes.re_root_empty,
+            None if self.do_not_error => self.tcx.lifetimes.re_static,
             None if generics.parent.is_some() => {
                 if let Some(hidden_ty) = self.hidden_ty.take() {
                     unexpected_hidden_region_diagnostic(
@@ -522,7 +512,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
                     )
                     .emit();
                 }
-                self.tcx.lifetimes.re_root_empty
+                self.tcx.lifetimes.re_static
             }
             None => {
                 self.tcx
@@ -574,7 +564,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
                 let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
                     if index < generics.parent_count {
                         // Accommodate missing regions in the parent kinds...
-                        self.fold_kind_mapping_missing_regions_to_empty(kind)
+                        self.fold_kind_no_missing_regions_error(kind)
                     } else {
                         // ...but not elsewhere.
                         self.fold_kind_normally(kind)
@@ -589,7 +579,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
                 let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
                     if index < generics.parent_count {
                         // Accommodate missing regions in the parent kinds...
-                        self.fold_kind_mapping_missing_regions_to_empty(kind)
+                        self.fold_kind_no_missing_regions_error(kind)
                     } else {
                         // ...but not elsewhere.
                         self.fold_kind_normally(kind)