about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmanda Stjerna <amanda.stjerna@it.uu.se>2025-08-06 16:58:42 +0200
committerAmanda Stjerna <amanda.stjerna@it.uu.se>2025-08-06 16:58:42 +0200
commit648e3fc3938b4b5127e7591187ce523e660ade44 (patch)
treeeb7df70aa2fcbb3bdc2fe898eb74ab3157afce1b
parent61e8869ed9aa8bf50a0ea2447a43bf856479feaa (diff)
downloadrust-648e3fc3938b4b5127e7591187ce523e660ade44.tar.gz
rust-648e3fc3938b4b5127e7591187ce523e660ade44.zip
Track names of existentials
-rw-r--r--compiler/rustc_borrowck/src/handle_placeholders.rs2
-rw-r--r--compiler/rustc_borrowck/src/region_infer/graphviz.rs3
-rw-r--r--compiler/rustc_borrowck/src/region_infer/mod.rs4
-rw-r--r--compiler/rustc_borrowck/src/renumber.rs2
-rw-r--r--compiler/rustc_borrowck/src/type_check/relate_tys.rs2
-rw-r--r--compiler/rustc_infer/src/infer/mod.rs1
6 files changed, 8 insertions, 6 deletions
diff --git a/compiler/rustc_borrowck/src/handle_placeholders.rs b/compiler/rustc_borrowck/src/handle_placeholders.rs
index aaaf2f45c86..5eec121b8a7 100644
--- a/compiler/rustc_borrowck/src/handle_placeholders.rs
+++ b/compiler/rustc_borrowck/src/handle_placeholders.rs
@@ -157,7 +157,7 @@ fn region_definitions<'tcx>(
     for info in var_infos.iter() {
         let origin = match info.origin {
             RegionVariableOrigin::Nll(origin) => origin,
-            _ => NllRegionVariableOrigin::Existential { from_forall: false },
+            _ => NllRegionVariableOrigin::Existential { from_forall: false, name: None },
         };
 
         let definition = RegionDefinition { origin, universe: info.universe, external_name: None };
diff --git a/compiler/rustc_borrowck/src/region_infer/graphviz.rs b/compiler/rustc_borrowck/src/region_infer/graphviz.rs
index ae4efddea4a..b2f67c43125 100644
--- a/compiler/rustc_borrowck/src/region_infer/graphviz.rs
+++ b/compiler/rustc_borrowck/src/region_infer/graphviz.rs
@@ -52,7 +52,8 @@ fn render_region_vid<'tcx>(
                 bug!("only used for pretty printing")
             }
         },
-        NllRegionVariableOrigin::Existential { .. } => " (ex<'?>)".to_string(),
+        NllRegionVariableOrigin::Existential { name: Some(name), .. } => format!(" (ex<{name}>)"),
+        NllRegionVariableOrigin::Existential { .. } => format!(" (ex<'_>)"),
     };
 
     format!("{:?}{universe_str}{external_name_str}{extra_info}", rvid)
diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs
index f1320048533..6ac908fd04c 100644
--- a/compiler/rustc_borrowck/src/region_infer/mod.rs
+++ b/compiler/rustc_borrowck/src/region_infer/mod.rs
@@ -1940,9 +1940,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         // and here we prefer to blame the source (the y = x statement).
         let blame_source = match from_region_origin {
             NllRegionVariableOrigin::FreeRegion
-            | NllRegionVariableOrigin::Existential { from_forall: false } => true,
+            | NllRegionVariableOrigin::Existential { from_forall: false, name: _ } => true,
             NllRegionVariableOrigin::Placeholder(_)
-            | NllRegionVariableOrigin::Existential { from_forall: true } => false,
+            | NllRegionVariableOrigin::Existential { from_forall: true, name: _ } => false,
         };
 
         // To pick a constraint to blame, we organize constraints by how interesting we expect them
diff --git a/compiler/rustc_borrowck/src/renumber.rs b/compiler/rustc_borrowck/src/renumber.rs
index ff92b4168a8..100d30704b9 100644
--- a/compiler/rustc_borrowck/src/renumber.rs
+++ b/compiler/rustc_borrowck/src/renumber.rs
@@ -66,7 +66,7 @@ impl<'a, 'tcx> RegionRenumberer<'a, 'tcx> {
         T: TypeFoldable<TyCtxt<'tcx>>,
         F: Fn() -> RegionCtxt,
     {
-        let origin = NllRegionVariableOrigin::Existential { from_forall: false };
+        let origin = NllRegionVariableOrigin::Existential { from_forall: false, name: None };
         fold_regions(self.infcx.tcx, value, |_region, _depth| {
             self.infcx.next_nll_region_var(origin, || region_ctxt_fn())
         })
diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs
index bb72d1d52f3..393adafea0b 100644
--- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs
+++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs
@@ -249,7 +249,7 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
         from_forall: bool,
         name: Option<Symbol>,
     ) -> ty::Region<'tcx> {
-        let origin = NllRegionVariableOrigin::Existential { from_forall };
+        let origin = NllRegionVariableOrigin::Existential { name, from_forall };
 
         let reg_var =
             self.type_checker.infcx.next_nll_region_var(origin, || RegionCtxt::Existential(name));
diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
index 7379df7c7c7..a2afdc45fa8 100644
--- a/compiler/rustc_infer/src/infer/mod.rs
+++ b/compiler/rustc_infer/src/infer/mod.rs
@@ -484,6 +484,7 @@ pub enum NllRegionVariableOrigin {
     Placeholder(ty::PlaceholderRegion),
 
     Existential {
+        name: Option<Symbol>,
         /// If this is true, then this variable was created to represent a lifetime
         /// bound in a `for` binder. For example, it might have been created to
         /// represent the lifetime `'a` in a type like `for<'a> fn(&'a u32)`.