about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
diff options
context:
space:
mode:
authorAmanda Stjerna <amanda.stjerna@it.uu.se>2024-05-17 15:11:59 +0200
committerAmanda Stjerna <amanda.stjerna@it.uu.se>2024-06-12 15:47:32 +0200
commit905db03b2869d6c53893ccddd84d8b2fd3c48273 (patch)
tree8a6ca2b5e6eb5d63efc32a101358f7b015261d96 /compiler/rustc_borrowck/src
parentd2a01760bcc82302464632e38d2108e06c2a8dd9 (diff)
Simplify path compression logic
Diffstat (limited to 'compiler/rustc_borrowck/src')
-rw-r--r--compiler/rustc_borrowck/src/constraints/mod.rs13
-rw-r--r--compiler/rustc_borrowck/src/region_infer/mod.rs2
2 files changed, 12 insertions, 3 deletions
diff --git a/compiler/rustc_borrowck/src/constraints/mod.rs b/compiler/rustc_borrowck/src/constraints/mod.rs
index b1d6fd89e27..ecb05eb09a4 100644
--- a/compiler/rustc_borrowck/src/constraints/mod.rs
+++ b/compiler/rustc_borrowck/src/constraints/mod.rs
@@ -62,15 +62,22 @@ impl scc::Annotation for RegionTracker {
 
 impl RegionTracker {
     pub fn new(rvid: RegionVid, definition: &RegionDefinition<'_>) -> Self {
+        let (representative_is_placeholder, representative_is_existential) = match definition.origin {
+            rustc_infer::infer::NllRegionVariableOrigin::FreeRegion => (false, false),
+            rustc_infer::infer::NllRegionVariableOrigin::Placeholder(_) => (true, false),
+            rustc_infer::infer::NllRegionVariableOrigin::Existential { .. } => (false, true),
+        };
+
         let placeholder_universe =
-            if definition.is_placeholder() { definition.universe } else { UniverseIndex::ROOT };
+            if representative_is_placeholder { definition.universe } else { UniverseIndex::ROOT };
+
 
         Self {
             max_placeholder_universe_reached: placeholder_universe,
             min_reachable_universe: definition.universe,
             representative: rvid,
-            representative_is_placeholder: definition.is_placeholder(),
-            representative_is_existential: definition.is_existential(),
+            representative_is_placeholder,
+            representative_is_existential,
         }
     }
     pub fn universe(self) -> UniverseIndex {
diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs
index b2a91a58e5c..2f387e345ed 100644
--- a/compiler/rustc_borrowck/src/region_infer/mod.rs
+++ b/compiler/rustc_borrowck/src/region_infer/mod.rs
@@ -2163,10 +2163,12 @@ impl<'tcx> RegionDefinition<'tcx> {
         Self { origin, universe, external_name: None }
     }
 
+    #[inline(always)]
     pub fn is_placeholder(&self) -> bool {
         matches!(self.origin, NllRegionVariableOrigin::Placeholder(_))
     }
 
+    #[inline(always)]
     pub fn is_existential(&self) -> bool {
         matches!(self.origin, NllRegionVariableOrigin::Existential { .. })
     }