Rename to was_placeholder to from_forall

This commit is contained in:
Aaron Hill 2019-10-01 21:39:19 -04:00
parent 1caa6dc546
commit 9c5a5c471a
No known key found for this signature in database
GPG Key ID: B4087E510E98B164
5 changed files with 18 additions and 8 deletions

View File

@ -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
},
}

View File

@ -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
}
};

View File

@ -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 }

View File

@ -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)
})
}

View File

@ -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)
}