about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_borrowck/src/polonius/liveness_constraints.rs29
-rw-r--r--compiler/rustc_borrowck/src/universal_regions.rs2
2 files changed, 24 insertions, 7 deletions
diff --git a/compiler/rustc_borrowck/src/polonius/liveness_constraints.rs b/compiler/rustc_borrowck/src/polonius/liveness_constraints.rs
index 950fef27286..75ee29c9d0d 100644
--- a/compiler/rustc_borrowck/src/polonius/liveness_constraints.rs
+++ b/compiler/rustc_borrowck/src/polonius/liveness_constraints.rs
@@ -231,17 +231,34 @@ struct VarianceExtractor<'a, 'tcx> {
 impl<'tcx> VarianceExtractor<'_, 'tcx> {
     fn record_variance(&mut self, region: ty::Region<'tcx>, variance: ty::Variance) {
         // We're only interested in the variance of vars and free regions.
+        //
+        // Note: even if we currently bail for two cases of unexpected region kinds here, missing
+        // variance data is not a soundness problem: the regions with missing variance will still be
+        // present in the constraint graph as they are live, and liveness edges construction has a
+        // fallback for this case.
+        //
+        // FIXME: that being said, we need to investigate these cases better to not ignore regions
+        // in general.
+        if region.is_bound() {
+            // We ignore these because they cannot be turned into the vids we need.
+            return;
+        }
 
-        if region.is_bound() || region.is_erased() {
-            // ignore these
+        if region.is_erased() {
+            // These cannot be turned into a vid either, and we also ignore them: the fact that they
+            // show up here looks like either an issue upstream or a combination with unexpectedly
+            // continuing compilation too far when we're in a tainted by errors situation.
+            //
+            // FIXME: investigate the `generic_const_exprs` test that triggers this issue,
+            // `ui/const-generics/generic_const_exprs/issue-97047-ice-2.rs`
             return;
         }
 
         let direction = match variance {
-            ty::Variance::Covariant => ConstraintDirection::Forward,
-            ty::Variance::Contravariant => ConstraintDirection::Backward,
-            ty::Variance::Invariant => ConstraintDirection::Bidirectional,
-            ty::Variance::Bivariant => {
+            ty::Covariant => ConstraintDirection::Forward,
+            ty::Contravariant => ConstraintDirection::Backward,
+            ty::Invariant => ConstraintDirection::Bidirectional,
+            ty::Bivariant => {
                 // We don't add edges for bivariant cases.
                 return;
             }
diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
index 1ac45cbea38..3dc4569c57b 100644
--- a/compiler/rustc_borrowck/src/universal_regions.rs
+++ b/compiler/rustc_borrowck/src/universal_regions.rs
@@ -337,7 +337,7 @@ impl<'tcx> UniversalRegions<'tcx> {
         self.indices.indices.iter().map(|(&r, &v)| (r, v))
     }
 
-    /// See `UniversalRegionIndices::to_region_vid`.
+    /// See [UniversalRegionIndices::to_region_vid].
     pub(crate) fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
         self.indices.to_region_vid(r)
     }