Skip to content

Commit 7efc731

Browse files
committed
remove from_forall
1 parent a6620a4 commit 7efc731

File tree

5 files changed

+15
-29
lines changed

5 files changed

+15
-29
lines changed

compiler/rustc_borrowck/src/handle_placeholders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn region_definitions<'tcx>(
157157
for info in var_infos.iter() {
158158
let origin = match info.origin {
159159
RegionVariableOrigin::Nll(origin) => origin,
160-
_ => NllRegionVariableOrigin::Existential { from_forall: false, name: None },
160+
_ => NllRegionVariableOrigin::Existential { name: None },
161161
};
162162

163163
let definition = RegionDefinition { origin, universe: info.universe, external_name: None };

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,10 +1939,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
19391939
//
19401940
// and here we prefer to blame the source (the y = x statement).
19411941
let blame_source = match from_region_origin {
1942-
NllRegionVariableOrigin::FreeRegion
1943-
| NllRegionVariableOrigin::Existential { from_forall: false, name: _ } => true,
1944-
NllRegionVariableOrigin::Placeholder(_)
1945-
| NllRegionVariableOrigin::Existential { from_forall: true, name: _ } => false,
1942+
NllRegionVariableOrigin::FreeRegion => true,
1943+
NllRegionVariableOrigin::Placeholder(_) => false,
1944+
// `'existential: 'whatever` never results in a region error by itself.
1945+
// We may always infer it to `'static` afterall. This means while an error
1946+
// path may go through an existential, these existentials are never the
1947+
// `from_region`.
1948+
NllRegionVariableOrigin::Existential { name: _ } => {
1949+
unreachable!("existentials can outlive everything")
1950+
}
19461951
};
19471952

19481953
// To pick a constraint to blame, we organize constraints by how interesting we expect them

compiler/rustc_borrowck/src/renumber.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'a, 'tcx> RegionRenumberer<'a, 'tcx> {
6666
T: TypeFoldable<TyCtxt<'tcx>>,
6767
F: Fn() -> RegionCtxt,
6868
{
69-
let origin = NllRegionVariableOrigin::Existential { from_forall: false, name: None };
69+
let origin = NllRegionVariableOrigin::Existential { name: None };
7070
fold_regions(self.infcx.tcx, value, |_region, _depth| {
7171
self.infcx.next_nll_region_var(origin, || region_ctxt_fn())
7272
})

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
216216
*ex_reg_var
217217
} else {
218218
let ex_reg_var =
219-
self.next_existential_region_var(true, br.kind.get_name(infcx.infcx.tcx));
219+
self.next_existential_region_var(br.kind.get_name(infcx.infcx.tcx));
220220
debug!(?ex_reg_var);
221221
reg_map.insert(br, ex_reg_var);
222222

@@ -244,17 +244,9 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
244244
}
245245

246246
#[instrument(skip(self), level = "debug")]
247-
fn next_existential_region_var(
248-
&mut self,
249-
from_forall: bool,
250-
name: Option<Symbol>,
251-
) -> ty::Region<'tcx> {
252-
let origin = NllRegionVariableOrigin::Existential { name, from_forall };
253-
254-
let reg_var =
255-
self.type_checker.infcx.next_nll_region_var(origin, || RegionCtxt::Existential(name));
256-
257-
reg_var
247+
fn next_existential_region_var(&mut self, name: Option<Symbol>) -> ty::Region<'tcx> {
248+
let origin = NllRegionVariableOrigin::Existential { name };
249+
self.type_checker.infcx.next_nll_region_var(origin, || RegionCtxt::Existential(name))
258250
}
259251

260252
#[instrument(skip(self), level = "debug")]

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,6 @@ pub enum NllRegionVariableOrigin {
485485

486486
Existential {
487487
name: Option<Symbol>,
488-
/// If this is true, then this variable was created to represent a lifetime
489-
/// bound in a `for` binder. For example, it might have been created to
490-
/// represent the lifetime `'a` in a type like `for<'a> fn(&'a u32)`.
491-
/// Such variables are created when we are trying to figure out if there
492-
/// is any valid instantiation of `'a` that could fit into some scenario.
493-
///
494-
/// This is used to inform error reporting: in the case that we are trying to
495-
/// determine whether there is any valid instantiation of a `'a` variable that meets
496-
/// some constraint C, we want to blame the "source" of that `for` type,
497-
/// rather than blaming the source of the constraint C.
498-
from_forall: bool,
499488
},
500489
}
501490

0 commit comments

Comments
 (0)