rename nonlexical_regioncx -> regioncx
This commit is contained in:
parent
66c5d5b706
commit
234b930108
@ -260,17 +260,11 @@ fn free_region_constraint_info(
|
||||
borrow_region: RegionVid,
|
||||
outlived_region: RegionVid,
|
||||
) -> (ConstraintCategory, bool, Span, Option<RegionName>) {
|
||||
let (category, from_closure, span) = self.nonlexical_regioncx.best_blame_constraint(
|
||||
let (category, from_closure, span) = self.regioncx.best_blame_constraint(
|
||||
&self.body,
|
||||
borrow_region,
|
||||
NLLRegionVariableOrigin::FreeRegion,
|
||||
|r| {
|
||||
self.nonlexical_regioncx.provides_universal_region(
|
||||
r,
|
||||
borrow_region,
|
||||
outlived_region,
|
||||
)
|
||||
},
|
||||
|r| self.regioncx.provides_universal_region(r, borrow_region, outlived_region),
|
||||
);
|
||||
|
||||
let mut renctx = RegionErrorNamingCtx::new();
|
||||
@ -303,15 +297,14 @@ pub(in crate::borrow_check) fn explain_why_borrow_contains_point(
|
||||
location, borrow, kind_place
|
||||
);
|
||||
|
||||
let regioncx = &self.nonlexical_regioncx;
|
||||
let regioncx = &self.regioncx;
|
||||
let body: &Body<'_> = &self.body;
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
let borrow_region_vid = borrow.region;
|
||||
debug!("explain_why_borrow_contains_point: borrow_region_vid={:?}", borrow_region_vid);
|
||||
|
||||
let region_sub =
|
||||
self.nonlexical_regioncx.find_sub_region_live_at(borrow_region_vid, location);
|
||||
let region_sub = self.regioncx.find_sub_region_live_at(borrow_region_vid, location);
|
||||
debug!("explain_why_borrow_contains_point: region_sub={:?}", region_sub);
|
||||
|
||||
match find_use::find(body, regioncx, tcx, region_sub, location) {
|
||||
|
@ -112,19 +112,18 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
/// to find a good name from that. Returns `None` if we can't find
|
||||
/// one (e.g., this is just some random part of the CFG).
|
||||
pub(super) fn to_error_region(&self, r: RegionVid) -> Option<ty::Region<'tcx>> {
|
||||
self.to_error_region_vid(r)
|
||||
.and_then(|r| self.nonlexical_regioncx.region_definition(r).external_name)
|
||||
self.to_error_region_vid(r).and_then(|r| self.regioncx.region_definition(r).external_name)
|
||||
}
|
||||
|
||||
/// Returns the `RegionVid` corresponding to the region returned by
|
||||
/// `to_error_region`.
|
||||
pub(super) fn to_error_region_vid(&self, r: RegionVid) -> Option<RegionVid> {
|
||||
if self.nonlexical_regioncx.universal_regions().is_universal_region(r) {
|
||||
if self.regioncx.universal_regions().is_universal_region(r) {
|
||||
Some(r)
|
||||
} else {
|
||||
let upper_bound = self.nonlexical_regioncx.universal_upper_bound(r);
|
||||
let upper_bound = self.regioncx.universal_upper_bound(r);
|
||||
|
||||
if self.nonlexical_regioncx.upper_bound_in_region_scc(r, upper_bound) {
|
||||
if self.regioncx.upper_bound_in_region_scc(r, upper_bound) {
|
||||
self.to_error_region_vid(upper_bound)
|
||||
} else {
|
||||
None
|
||||
@ -137,7 +136,7 @@ fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
|
||||
if let Some(ty::ReFree(free_region)) = self.to_error_region(fr) {
|
||||
if let ty::BoundRegion::BrEnv = free_region.bound_region {
|
||||
if let DefiningTy::Closure(def_id, substs) =
|
||||
self.nonlexical_regioncx.universal_regions().defining_ty
|
||||
self.regioncx.universal_regions().defining_ty
|
||||
{
|
||||
let closure_kind_ty = substs.as_closure().kind_ty(def_id, self.infcx.tcx);
|
||||
return Some(ty::ClosureKind::FnMut) == closure_kind_ty.to_opt_closure_kind();
|
||||
@ -219,11 +218,10 @@ pub(in crate::borrow_check) fn report_region_errors(&mut self, nll_errors: Regio
|
||||
fr_origin,
|
||||
error_element,
|
||||
} => {
|
||||
let error_region =
|
||||
self.nonlexical_regioncx.region_from_element(longer_fr, error_element);
|
||||
let error_region = self.regioncx.region_from_element(longer_fr, error_element);
|
||||
|
||||
// Find the code to blame for the fact that `longer_fr` outlives `error_fr`.
|
||||
let (_, span) = self.nonlexical_regioncx.find_outlives_blame_span(
|
||||
let (_, span) = self.regioncx.find_outlives_blame_span(
|
||||
&self.body,
|
||||
longer_fr,
|
||||
fr_origin,
|
||||
@ -286,8 +284,8 @@ pub(in crate::borrow_check) fn report_error(
|
||||
debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
|
||||
|
||||
let (category, _, span) =
|
||||
self.nonlexical_regioncx.best_blame_constraint(&self.body, fr, fr_origin, |r| {
|
||||
self.nonlexical_regioncx.provides_universal_region(r, fr, outlived_fr)
|
||||
self.regioncx.best_blame_constraint(&self.body, fr, fr_origin, |r| {
|
||||
self.regioncx.provides_universal_region(r, fr, outlived_fr)
|
||||
});
|
||||
|
||||
debug!("report_error: category={:?} {:?}", category, span);
|
||||
@ -302,8 +300,8 @@ pub(in crate::borrow_check) fn report_error(
|
||||
}
|
||||
|
||||
let (fr_is_local, outlived_fr_is_local): (bool, bool) = (
|
||||
self.nonlexical_regioncx.universal_regions().is_local_free_region(fr),
|
||||
self.nonlexical_regioncx.universal_regions().is_local_free_region(outlived_fr),
|
||||
self.regioncx.universal_regions().is_local_free_region(fr),
|
||||
self.regioncx.universal_regions().is_local_free_region(outlived_fr),
|
||||
);
|
||||
|
||||
debug!(
|
||||
@ -378,7 +376,7 @@ fn report_fnmut_error(
|
||||
// We should check if the return type of this closure is in fact a closure - in that
|
||||
// case, we can special case the error further.
|
||||
let return_type_is_closure =
|
||||
self.nonlexical_regioncx.universal_regions().unnormalized_output_ty.is_closure();
|
||||
self.regioncx.universal_regions().unnormalized_output_ty.is_closure();
|
||||
let message = if return_type_is_closure {
|
||||
"returns a closure that contains a reference to a captured variable, which then \
|
||||
escapes the closure body"
|
||||
@ -430,14 +428,14 @@ fn report_escaping_data_error(
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let ErrorConstraintInfo { span, category, .. } = errci;
|
||||
|
||||
let fr_name_and_span = self.nonlexical_regioncx.get_var_name_and_span_for_region(
|
||||
let fr_name_and_span = self.regioncx.get_var_name_and_span_for_region(
|
||||
self.infcx.tcx,
|
||||
&self.body,
|
||||
&self.local_names,
|
||||
&self.upvars,
|
||||
errci.fr,
|
||||
);
|
||||
let outlived_fr_name_and_span = self.nonlexical_regioncx.get_var_name_and_span_for_region(
|
||||
let outlived_fr_name_and_span = self.regioncx.get_var_name_and_span_for_region(
|
||||
self.infcx.tcx,
|
||||
&self.body,
|
||||
&self.local_names,
|
||||
@ -445,7 +443,7 @@ fn report_escaping_data_error(
|
||||
errci.outlived_fr,
|
||||
);
|
||||
|
||||
let escapes_from = match self.nonlexical_regioncx.universal_regions().defining_ty {
|
||||
let escapes_from = match self.regioncx.universal_regions().defining_ty {
|
||||
DefiningTy::Closure(..) => "closure",
|
||||
DefiningTy::Generator(..) => "generator",
|
||||
DefiningTy::FnDef(..) => "function",
|
||||
|
@ -191,7 +191,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
||||
) -> Option<RegionName> {
|
||||
debug!("give_region_a_name(fr={:?}, counter={:?})", fr, renctx.counter);
|
||||
|
||||
assert!(self.nonlexical_regioncx.universal_regions().is_universal_region(fr));
|
||||
assert!(self.regioncx.universal_regions().is_universal_region(fr));
|
||||
|
||||
if let Some(value) = renctx.get(&fr) {
|
||||
return Some(value.clone());
|
||||
@ -277,7 +277,7 @@ fn give_name_from_error_region(
|
||||
.hir()
|
||||
.as_local_hir_id(self.mir_def_id)
|
||||
.expect("non-local mir");
|
||||
let def_ty = self.nonlexical_regioncx.universal_regions().defining_ty;
|
||||
let def_ty = self.regioncx.universal_regions().defining_ty;
|
||||
|
||||
if let DefiningTy::Closure(def_id, substs) = def_ty {
|
||||
let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) =
|
||||
@ -344,12 +344,10 @@ fn give_name_if_anonymous_region_appears_in_arguments(
|
||||
fr: RegionVid,
|
||||
renctx: &mut RegionErrorNamingCtx,
|
||||
) -> Option<RegionName> {
|
||||
let implicit_inputs =
|
||||
self.nonlexical_regioncx.universal_regions().defining_ty.implicit_inputs();
|
||||
let argument_index =
|
||||
self.nonlexical_regioncx.get_argument_index_for_region(self.infcx.tcx, fr)?;
|
||||
let implicit_inputs = self.regioncx.universal_regions().defining_ty.implicit_inputs();
|
||||
let argument_index = self.regioncx.get_argument_index_for_region(self.infcx.tcx, fr)?;
|
||||
|
||||
let arg_ty = self.nonlexical_regioncx.universal_regions().unnormalized_input_tys
|
||||
let arg_ty = self.regioncx.universal_regions().unnormalized_input_tys
|
||||
[implicit_inputs + argument_index];
|
||||
if let Some(region_name) =
|
||||
self.give_name_if_we_can_match_hir_ty_from_argument(fr, arg_ty, argument_index, renctx)
|
||||
@ -415,10 +413,9 @@ fn give_name_if_we_cannot_match_hir_ty(
|
||||
);
|
||||
let assigned_region_name = if type_name.find(&format!("'{}", counter)).is_some() {
|
||||
// Only add a label if we can confirm that a region was labelled.
|
||||
let argument_index = self
|
||||
.nonlexical_regioncx
|
||||
.get_argument_index_for_region(self.infcx.tcx, needle_fr)?;
|
||||
let (_, span) = self.nonlexical_regioncx.get_argument_name_and_span_for_region(
|
||||
let argument_index =
|
||||
self.regioncx.get_argument_index_for_region(self.infcx.tcx, needle_fr)?;
|
||||
let (_, span) = self.regioncx.get_argument_name_and_span_for_region(
|
||||
&self.body,
|
||||
&self.local_names,
|
||||
argument_index,
|
||||
@ -658,9 +655,8 @@ fn give_name_if_anonymous_region_appears_in_upvars(
|
||||
fr: RegionVid,
|
||||
renctx: &mut RegionErrorNamingCtx,
|
||||
) -> Option<RegionName> {
|
||||
let upvar_index =
|
||||
self.nonlexical_regioncx.get_upvar_index_for_region(self.infcx.tcx, fr)?;
|
||||
let (upvar_name, upvar_span) = self.nonlexical_regioncx.get_upvar_name_and_span_for_region(
|
||||
let upvar_index = self.regioncx.get_upvar_index_for_region(self.infcx.tcx, fr)?;
|
||||
let (upvar_name, upvar_span) = self.regioncx.get_upvar_name_and_span_for_region(
|
||||
self.infcx.tcx,
|
||||
&self.upvars,
|
||||
upvar_index,
|
||||
@ -684,7 +680,7 @@ fn give_name_if_anonymous_region_appears_in_output(
|
||||
) -> Option<RegionName> {
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
let return_ty = self.nonlexical_regioncx.universal_regions().unnormalized_output_ty;
|
||||
let return_ty = self.regioncx.universal_regions().unnormalized_output_ty;
|
||||
debug!("give_name_if_anonymous_region_appears_in_output: return_ty = {:?}", return_ty);
|
||||
if !tcx.any_free_region_meets(&return_ty, |r| r.to_region_vid() == fr) {
|
||||
return None;
|
||||
@ -734,7 +730,7 @@ fn give_name_if_anonymous_region_appears_in_yield_ty(
|
||||
) -> Option<RegionName> {
|
||||
// Note: generators from `async fn` yield `()`, so we don't have to
|
||||
// worry about them here.
|
||||
let yield_ty = self.nonlexical_regioncx.universal_regions().yield_ty?;
|
||||
let yield_ty = self.regioncx.universal_regions().yield_ty?;
|
||||
debug!("give_name_if_anonymous_region_appears_in_yield_ty: yield_ty = {:?}", yield_ty,);
|
||||
|
||||
let tcx = self.infcx.tcx;
|
||||
|
@ -283,7 +283,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||
move_error_reported: BTreeMap::new(),
|
||||
uninitialized_error_reported: Default::default(),
|
||||
errors_buffer,
|
||||
nonlexical_regioncx: regioncx,
|
||||
regioncx,
|
||||
used_mut: Default::default(),
|
||||
used_mut_upvars: SmallVec::new(),
|
||||
borrow_set,
|
||||
@ -474,10 +474,9 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||
/// If the function we're checking is a closure, then we'll need to report back the list of
|
||||
/// mutable upvars that have been used. This field keeps track of them.
|
||||
used_mut_upvars: SmallVec<[Field; 8]>,
|
||||
/// Non-lexical region inference context, if NLL is enabled. This
|
||||
/// contains the results from region inference and lets us e.g.
|
||||
/// Region inference context. This contains the results from region inference and lets us e.g.
|
||||
/// find out which CFG points are contained in each borrow region.
|
||||
nonlexical_regioncx: Rc<RegionInferenceContext<'tcx>>,
|
||||
regioncx: Rc<RegionInferenceContext<'tcx>>,
|
||||
|
||||
/// The set of borrows extracted from the MIR
|
||||
borrow_set: Rc<BorrowSet<'tcx>>,
|
||||
|
Loading…
Reference in New Issue
Block a user