Skip to content

Commit

Permalink
Rename to was_placeholder to from_forall
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Oct 2, 2019
1 parent 1caa6dc commit 9c5a5c4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
12 changes: 11 additions & 1 deletion src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/nll/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/nll/renumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down

0 comments on commit 9c5a5c4

Please sign in to comment.