about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2019-10-01 21:39:19 -0400
committerAaron Hill <aa1ronham@gmail.com>2019-10-01 21:39:19 -0400
commit9c5a5c471aa9229b82bafa8ec18e55722d9ba8c3 (patch)
treeb9cf4bfe42842d8c7c8c356f7290a64f4648fe65
parent1caa6dc5461292611fcad75c8114c9fd35d7e923 (diff)
downloadrust-9c5a5c471aa9229b82bafa8ec18e55722d9ba8c3.tar.gz
rust-9c5a5c471aa9229b82bafa8ec18e55722d9ba8c3.zip
Rename to `was_placeholder` to `from_forall`
-rw-r--r--src/librustc/infer/mod.rs12
-rw-r--r--src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs4
-rw-r--r--src/librustc_mir/borrow_check/nll/region_infer/mod.rs2
-rw-r--r--src/librustc_mir/borrow_check/nll/renumber.rs2
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs6
5 files changed, 18 insertions, 8 deletions
diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs
index 99297d7222b..35db82406ab 100644
--- a/src/librustc/infer/mod.rs
+++ b/src/librustc/infer/mod.rs
@@ -419,7 +419,17 @@ pub enum NLLRegionVariableOrigin {
     Placeholder(ty::PlaceholderRegion),
 
     Existential {
-        was_placeholder: bool
+        /// 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)`.
+        /// Such variables are created when we are trying to figure out if there
+        /// is any valid instantiation of `'a` that could fit into some scenario.
+        ///
+        /// This is used to inform error reporting: in the case that we are trying to
+        /// determine whether there is any valid instantiation of a `'a` variable that meets
+        /// some constraint C, we want to blame the "source" of that `for` type,
+        /// rather than blaming the source of the constraint C.
+        from_forall: bool
     },
 }
 
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
index 826be88e365..fa02e2dd234 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
@@ -159,11 +159,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
 
         let should_reverse = match from_region_origin {
             NLLRegionVariableOrigin::FreeRegion
-                | NLLRegionVariableOrigin::Existential { was_placeholder: false  } => {
+                | NLLRegionVariableOrigin::Existential { from_forall: false  } => {
                     true
             }
             NLLRegionVariableOrigin::Placeholder(_)
-                | NLLRegionVariableOrigin::Existential { was_placeholder: true  } => {
+                | NLLRegionVariableOrigin::Existential { from_forall: true  } => {
                     false
             }
         };
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
index 164f7b0627c..dbb810db555 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
@@ -1612,7 +1612,7 @@ impl<'tcx> RegionDefinition<'tcx> {
 
         let origin = match rv_origin {
             RegionVariableOrigin::NLL(origin) => origin,
-            _ => NLLRegionVariableOrigin::Existential { was_placeholder: false },
+            _ => NLLRegionVariableOrigin::Existential { from_forall: false },
         };
 
         Self { origin, universe, external_name: None }
diff --git a/src/librustc_mir/borrow_check/nll/renumber.rs b/src/librustc_mir/borrow_check/nll/renumber.rs
index 6e4db36bdce..315c369716e 100644
--- a/src/librustc_mir/borrow_check/nll/renumber.rs
+++ b/src/librustc_mir/borrow_check/nll/renumber.rs
@@ -35,7 +35,7 @@ where
     infcx
         .tcx
         .fold_regions(value, &mut false, |_region, _depth| {
-            let origin = NLLRegionVariableOrigin::Existential { was_placeholder: false };
+            let origin = NLLRegionVariableOrigin::Existential { from_forall: false };
             infcx.next_nll_region_var(origin)
         })
 }
diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
index 919fcdbd39b..80bf0478128 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
@@ -66,9 +66,9 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
         self.infcx.create_next_universe()
     }
 
-    fn next_existential_region_var(&mut self, was_placeholder: bool) -> ty::Region<'tcx> {
+    fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> {
         if let Some(_) = &mut self.borrowck_context {
-            let origin = NLLRegionVariableOrigin::Existential { was_placeholder };
+            let origin = NLLRegionVariableOrigin::Existential { from_forall };
             self.infcx.next_nll_region_var(origin)
         } else {
             self.infcx.tcx.lifetimes.re_erased
@@ -89,7 +89,7 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
     fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> {
         self.infcx
             .next_nll_region_var_in_universe(NLLRegionVariableOrigin::Existential {
-                was_placeholder: false
+                from_forall: false
             }, universe)
     }