Skip to content

Commit 9c5a5c4

Browse files
committed
Rename to was_placeholder to from_forall
1 parent 1caa6dc commit 9c5a5c4

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

src/librustc/infer/mod.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,17 @@ pub enum NLLRegionVariableOrigin {
419419
Placeholder(ty::PlaceholderRegion),
420420

421421
Existential {
422-
was_placeholder: bool
422+
/// If this is true, then this variable was created to represent a lifetime
423+
/// bound in a `for` binder. For example, it might have been created to
424+
/// represent the lifetime `'a` in a type like `for<'a> fn(&'a u32)`.
425+
/// Such variables are created when we are trying to figure out if there
426+
/// is any valid instantiation of `'a` that could fit into some scenario.
427+
///
428+
/// This is used to inform error reporting: in the case that we are trying to
429+
/// determine whether there is any valid instantiation of a `'a` variable that meets
430+
/// some constraint C, we want to blame the "source" of that `for` type,
431+
/// rather than blaming the source of the constraint C.
432+
from_forall: bool
423433
},
424434
}
425435

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
159159

160160
let should_reverse = match from_region_origin {
161161
NLLRegionVariableOrigin::FreeRegion
162-
| NLLRegionVariableOrigin::Existential { was_placeholder: false } => {
162+
| NLLRegionVariableOrigin::Existential { from_forall: false } => {
163163
true
164164
}
165165
NLLRegionVariableOrigin::Placeholder(_)
166-
| NLLRegionVariableOrigin::Existential { was_placeholder: true } => {
166+
| NLLRegionVariableOrigin::Existential { from_forall: true } => {
167167
false
168168
}
169169
};

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ impl<'tcx> RegionDefinition<'tcx> {
16121612

16131613
let origin = match rv_origin {
16141614
RegionVariableOrigin::NLL(origin) => origin,
1615-
_ => NLLRegionVariableOrigin::Existential { was_placeholder: false },
1615+
_ => NLLRegionVariableOrigin::Existential { from_forall: false },
16161616
};
16171617

16181618
Self { origin, universe, external_name: None }

src/librustc_mir/borrow_check/nll/renumber.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ where
3535
infcx
3636
.tcx
3737
.fold_regions(value, &mut false, |_region, _depth| {
38-
let origin = NLLRegionVariableOrigin::Existential { was_placeholder: false };
38+
let origin = NLLRegionVariableOrigin::Existential { from_forall: false };
3939
infcx.next_nll_region_var(origin)
4040
})
4141
}

src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
6666
self.infcx.create_next_universe()
6767
}
6868

69-
fn next_existential_region_var(&mut self, was_placeholder: bool) -> ty::Region<'tcx> {
69+
fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> {
7070
if let Some(_) = &mut self.borrowck_context {
71-
let origin = NLLRegionVariableOrigin::Existential { was_placeholder };
71+
let origin = NLLRegionVariableOrigin::Existential { from_forall };
7272
self.infcx.next_nll_region_var(origin)
7373
} else {
7474
self.infcx.tcx.lifetimes.re_erased
@@ -89,7 +89,7 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
8989
fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> {
9090
self.infcx
9191
.next_nll_region_var_in_universe(NLLRegionVariableOrigin::Existential {
92-
was_placeholder: false
92+
from_forall: false
9393
}, universe)
9494
}
9595

0 commit comments

Comments
 (0)