//! Error reporting machinery for lifetime errors.
-use rustc::infer::{
- error_reporting::nice_region_error::NiceRegionError, InferCtxt, NLLRegionVariableOrigin,
-};
+use rustc::infer::{error_reporting::nice_region_error::NiceRegionError, NLLRegionVariableOrigin};
use rustc::mir::ConstraintCategory;
use rustc::ty::{self, RegionVid, Ty};
use rustc_errors::{Applicability, DiagnosticBuilder};
use crate::borrow_check::{
nll::ConstraintDescription,
- region_infer::{values::RegionElement, RegionInferenceContext, TypeTest},
+ region_infer::{values::RegionElement, TypeTest},
universal_regions::DefiningTy,
MirBorrowckCtxt,
};
pub(super) span: Span,
}
-impl<'tcx> RegionInferenceContext<'tcx> {
+impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
/// Converts a region inference variable into a `ty::Region` that
/// we can use for error reporting. If `r` is universally bound,
/// then we use the name that we have on record for it. If `r` is
/// existentially bound, then we check its inferred value and try
/// 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 fn to_error_region(&self, r: RegionVid) -> Option<ty::Region<'tcx>> {
- self.to_error_region_vid(r).and_then(|r| self.definitions[r].external_name)
+ // TODO(mark-i-m): make this private when we move report_region_errors here...
+ crate fn to_error_region(&self, r: RegionVid) -> Option<ty::Region<'tcx>> {
+ self.to_error_region_vid(r)
+ .and_then(|r| self.nonlexical_regioncx.definitions[r].external_name)
}
- /// Returns the [RegionVid] corresponding to the region returned by
+ /// Returns the `RegionVid` corresponding to the region returned by
/// `to_error_region`.
- pub fn to_error_region_vid(&self, r: RegionVid) -> Option<RegionVid> {
- if self.universal_regions.is_universal_region(r) {
+ pub(super) fn to_error_region_vid(&self, r: RegionVid) -> Option<RegionVid> {
+ if self.nonlexical_regioncx.universal_regions.is_universal_region(r) {
Some(r)
} else {
- let r_scc = self.constraint_sccs.scc(r);
- let upper_bound = self.universal_upper_bound(r);
- if self.scc_values.contains(r_scc, upper_bound) {
+ let r_scc = self.nonlexical_regioncx.constraint_sccs.scc(r);
+ let upper_bound = self.nonlexical_regioncx.universal_upper_bound(r);
+ if self.nonlexical_regioncx.scc_values.contains(r_scc, upper_bound) {
self.to_error_region_vid(upper_bound)
} else {
None
}
/// Returns `true` if a closure is inferred to be an `FnMut` closure.
- crate fn is_closure_fn_mut(&self, infcx: &InferCtxt<'_, 'tcx>, fr: RegionVid) -> bool {
+ 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.universal_regions.defining_ty {
- let closure_kind_ty = substs.as_closure().kind_ty(def_id, infcx.tcx);
+ if let DefiningTy::Closure(def_id, substs) =
+ self.nonlexical_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();
}
}
/// ```
///
/// Here we would be invoked with `fr = 'a` and `outlived_fr = `'b`.
- pub(in crate::borrow_check) fn report_error<'a>(
- &'a self,
- mbcx: &MirBorrowckCtxt<'a, 'tcx>,
+ pub(in crate::borrow_check) fn report_error(
+ &mut self,
fr: RegionVid,
fr_origin: NLLRegionVariableOrigin,
outlived_fr: RegionVid,
outlives_suggestion: &mut OutlivesSuggestionBuilder,
renctx: &mut RegionErrorNamingCtx,
- ) -> DiagnosticBuilder<'a> {
+ ) {
debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
- let (category, _, span) = self.best_blame_constraint(&mbcx.body, fr, fr_origin, |r| {
- self.provides_universal_region(r, 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)
+ });
debug!("report_error: category={:?} {:?}", category, span);
// Check if we can use one of the "nice region errors".
if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
- let tables = mbcx.infcx.tcx.typeck_tables_of(mbcx.mir_def_id);
- let nice = NiceRegionError::new_from_span(mbcx.infcx, span, o, f, Some(tables));
+ let tables = self.infcx.tcx.typeck_tables_of(self.mir_def_id);
+ let nice = NiceRegionError::new_from_span(self.infcx, span, o, f, Some(tables));
if let Some(diag) = nice.try_report_from_nll() {
- return diag;
+ diag.buffer(&mut self.errors_buffer);
+ return;
}
}
let (fr_is_local, outlived_fr_is_local): (bool, bool) = (
- self.universal_regions.is_local_free_region(fr),
- self.universal_regions.is_local_free_region(outlived_fr),
+ self.nonlexical_regioncx.universal_regions.is_local_free_region(fr),
+ self.nonlexical_regioncx.universal_regions.is_local_free_region(outlived_fr),
);
debug!(
span,
};
- match (category, fr_is_local, outlived_fr_is_local) {
- (ConstraintCategory::Return, true, false) if self.is_closure_fn_mut(mbcx.infcx, fr) => {
- self.report_fnmut_error(mbcx, &errci, renctx)
+ let diag = match (category, fr_is_local, outlived_fr_is_local) {
+ (ConstraintCategory::Return, true, false) if self.is_closure_fn_mut(fr) => {
+ self.report_fnmut_error(&errci, renctx)
}
(ConstraintCategory::Assignment, true, false)
| (ConstraintCategory::CallArgument, true, false) => {
- let mut db = self.report_escaping_data_error(mbcx, &errci, renctx);
+ let mut db = self.report_escaping_data_error(&errci, renctx);
- outlives_suggestion.intermediate_suggestion(mbcx, &errci, renctx, &mut db);
+ outlives_suggestion.intermediate_suggestion(self, &errci, renctx, &mut db);
outlives_suggestion.collect_constraint(fr, outlived_fr);
db
}
_ => {
- let mut db = self.report_general_error(mbcx, &errci, renctx);
+ let mut db = self.report_general_error(&errci, renctx);
- outlives_suggestion.intermediate_suggestion(mbcx, &errci, renctx, &mut db);
+ outlives_suggestion.intermediate_suggestion(self, &errci, renctx, &mut db);
outlives_suggestion.collect_constraint(fr, outlived_fr);
db
}
- }
+ };
+
+ diag.buffer(&mut self.errors_buffer);
}
/// Report a specialized error when `FnMut` closures return a reference to a captured variable.
/// ```
fn report_fnmut_error(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
errci: &ErrorConstraintInfo,
renctx: &mut RegionErrorNamingCtx,
- ) -> DiagnosticBuilder<'_> {
+ ) -> DiagnosticBuilder<'tcx> {
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
- let mut diag = mbcx
+ let mut diag = self
.infcx
.tcx
.sess
// 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.universal_regions.unnormalized_output_ty.is_closure();
+ let return_type_is_closure =
+ self.nonlexical_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"
diag.span_label(*span, message);
- match self.give_region_a_name(mbcx, renctx, *outlived_fr).unwrap().source {
+ match self.give_region_a_name(renctx, *outlived_fr).unwrap().source {
RegionNameSource::NamedEarlyBoundRegion(fr_span)
| RegionNameSource::NamedFreeRegion(fr_span)
| RegionNameSource::SynthesizedFreeEnvRegion(fr_span, _)
/// ```
fn report_escaping_data_error(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
errci: &ErrorConstraintInfo,
renctx: &mut RegionErrorNamingCtx,
- ) -> DiagnosticBuilder<'_> {
+ ) -> DiagnosticBuilder<'tcx> {
let ErrorConstraintInfo { span, category, .. } = errci;
- let fr_name_and_span = self.get_var_name_and_span_for_region(
- mbcx.infcx.tcx,
- &mbcx.body,
- &mbcx.local_names,
- &mbcx.upvars,
+ let fr_name_and_span = self.nonlexical_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.get_var_name_and_span_for_region(
- mbcx.infcx.tcx,
- &mbcx.body,
- &mbcx.local_names,
- &mbcx.upvars,
+ let outlived_fr_name_and_span = self.nonlexical_regioncx.get_var_name_and_span_for_region(
+ self.infcx.tcx,
+ &self.body,
+ &self.local_names,
+ &self.upvars,
errci.outlived_fr,
);
- let escapes_from = match self.universal_regions.defining_ty {
+ let escapes_from = match self.nonlexical_regioncx.universal_regions.defining_ty {
DefiningTy::Closure(..) => "closure",
DefiningTy::Generator(..) => "generator",
DefiningTy::FnDef(..) => "function",
|| escapes_from == "const"
{
return self.report_general_error(
- mbcx,
&ErrorConstraintInfo { fr_is_local: true, outlived_fr_is_local: false, ..*errci },
renctx,
);
}
let mut diag =
- borrowck_errors::borrowed_data_escapes_closure(mbcx.infcx.tcx, *span, escapes_from);
+ borrowck_errors::borrowed_data_escapes_closure(self.infcx.tcx, *span, escapes_from);
if let Some((Some(outlived_fr_name), outlived_fr_span)) = outlived_fr_name_and_span {
diag.span_label(
/// ```
fn report_general_error(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
errci: &ErrorConstraintInfo,
renctx: &mut RegionErrorNamingCtx,
- ) -> DiagnosticBuilder<'_> {
+ ) -> DiagnosticBuilder<'tcx> {
let ErrorConstraintInfo {
fr,
fr_is_local,
} = errci;
let mut diag =
- mbcx.infcx.tcx.sess.struct_span_err(*span, "lifetime may not live long enough");
+ self.infcx.tcx.sess.struct_span_err(*span, "lifetime may not live long enough");
let mir_def_name =
- if mbcx.infcx.tcx.is_closure(mbcx.mir_def_id) { "closure" } else { "function" };
+ if self.infcx.tcx.is_closure(self.mir_def_id) { "closure" } else { "function" };
- let fr_name = self.give_region_a_name(mbcx, renctx, *fr).unwrap();
+ let fr_name = self.give_region_a_name(renctx, *fr).unwrap();
fr_name.highlight_region_name(&mut diag);
- let outlived_fr_name = self.give_region_a_name(mbcx, renctx, *outlived_fr).unwrap();
+ let outlived_fr_name = self.give_region_a_name(renctx, *outlived_fr).unwrap();
outlived_fr_name.highlight_region_name(&mut diag);
match (category, outlived_fr_is_local, fr_is_local) {
}
}
- self.add_static_impl_trait_suggestion(mbcx.infcx, &mut diag, *fr, fr_name, *outlived_fr);
+ self.add_static_impl_trait_suggestion(&mut diag, *fr, fr_name, *outlived_fr);
diag
}
/// ```
fn add_static_impl_trait_suggestion(
&self,
- infcx: &InferCtxt<'_, 'tcx>,
- diag: &mut DiagnosticBuilder<'_>,
+ diag: &mut DiagnosticBuilder<'tcx>,
fr: RegionVid,
// We need to pass `fr_name` - computing it again will label it twice.
fr_name: RegionName,
if let (Some(f), Some(ty::RegionKind::ReStatic)) =
(self.to_error_region(fr), self.to_error_region(outlived_fr))
{
- if let Some((ty::TyS { kind: ty::Opaque(did, substs), .. }, _)) = infcx
+ if let Some((ty::TyS { kind: ty::Opaque(did, substs), .. }, _)) = self
+ .infcx
.tcx
.is_suitable_region(f)
.map(|r| r.def_id)
- .map(|id| infcx.tcx.return_type_impl_trait(id))
+ .map(|id| self.infcx.tcx.return_type_impl_trait(id))
.unwrap_or(None)
{
// Check whether or not the impl trait return type is intended to capture
//
// eg. check for `impl Trait + 'static` instead of `impl Trait`.
let has_static_predicate = {
- let predicates_of = infcx.tcx.predicates_of(*did);
- let bounds = predicates_of.instantiate(infcx.tcx, substs);
+ let predicates_of = self.infcx.tcx.predicates_of(*did);
+ let bounds = predicates_of.instantiate(self.infcx.tcx, substs);
let mut found = false;
for predicate in bounds.predicates {
diag.help(&format!("consider replacing `{}` with `{}`", fr_name, static_str));
} else {
// Otherwise, we should suggest adding a constraint on the return type.
- let span = infcx.tcx.def_span(*did);
- if let Ok(snippet) = infcx.tcx.sess.source_map().span_to_snippet(span) {
+ let span = self.infcx.tcx.def_span(*did);
+ if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) {
let suggestable_fr_name = if fr_name.was_named() {
fr_name.to_string()
} else {
use rustc::ty::print::RegionHighlightMode;
use rustc::ty::subst::{GenericArgKind, SubstsRef};
-use rustc::ty::{self, RegionVid, Ty, TyCtxt};
+use rustc::ty::{self, RegionVid, Ty};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::DiagnosticBuilder;
use rustc_hir as hir;
use rustc_span::symbol::kw;
use rustc_span::{symbol::Symbol, Span, DUMMY_SP};
-use crate::borrow_check::{
- nll::ToRegionVid, region_infer::RegionInferenceContext, universal_regions::DefiningTy,
- MirBorrowckCtxt,
-};
+use crate::borrow_check::{nll::ToRegionVid, universal_regions::DefiningTy, MirBorrowckCtxt};
/// A name for a particular region used in emitting diagnostics. This name could be a generated
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
}
}
-impl<'tcx> RegionInferenceContext<'tcx> {
+impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
/// Maps from an internal MIR region vid to something that we can
/// report to the user. In some cases, the region vids will map
/// directly to lifetimes that the user has a name for (e.g.,
/// and then return the name `'1` for us to use.
crate fn give_region_a_name(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
renctx: &mut RegionErrorNamingCtx,
fr: RegionVid,
) -> Option<RegionName> {
debug!("give_region_a_name(fr={:?}, counter={:?})", fr, renctx.counter);
- assert!(self.universal_regions.is_universal_region(fr));
+ assert!(self.nonlexical_regioncx.universal_regions.is_universal_region(fr));
if let Some(value) = renctx.get(&fr) {
return Some(value.clone());
}
let value = self
- .give_name_from_error_region(mbcx, fr, renctx)
- .or_else(|| self.give_name_if_anonymous_region_appears_in_arguments(mbcx, fr, renctx))
- .or_else(|| self.give_name_if_anonymous_region_appears_in_upvars(mbcx, fr, renctx))
- .or_else(|| self.give_name_if_anonymous_region_appears_in_output(mbcx, fr, renctx))
- .or_else(|| self.give_name_if_anonymous_region_appears_in_yield_ty(mbcx, fr, renctx));
+ .give_name_from_error_region(fr, renctx)
+ .or_else(|| self.give_name_if_anonymous_region_appears_in_arguments(fr, renctx))
+ .or_else(|| self.give_name_if_anonymous_region_appears_in_upvars(fr, renctx))
+ .or_else(|| self.give_name_if_anonymous_region_appears_in_output(fr, renctx))
+ .or_else(|| self.give_name_if_anonymous_region_appears_in_yield_ty(fr, renctx));
if let Some(ref value) = value {
renctx.insert(fr, value.clone());
/// named variants.
fn give_name_from_error_region(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
fr: RegionVid,
renctx: &mut RegionErrorNamingCtx,
) -> Option<RegionName> {
let error_region = self.to_error_region(fr)?;
- let tcx = mbcx.infcx.tcx;
+ let tcx = self.infcx.tcx;
debug!("give_region_a_name: error_region = {:?}", error_region);
match error_region {
}
ty::BoundRegion::BrEnv => {
- let mir_hir_id = mbcx
+ let mir_hir_id = self
.infcx
.tcx
.hir()
- .as_local_hir_id(mbcx.mir_def_id)
+ .as_local_hir_id(self.mir_def_id)
.expect("non-local mir");
- let def_ty = self.universal_regions.defining_ty;
+ let def_ty = self.nonlexical_regioncx.universal_regions.defining_ty;
if let DefiningTy::Closure(def_id, substs) = def_ty {
let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) =
/// ```
fn give_name_if_anonymous_region_appears_in_arguments(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
fr: RegionVid,
renctx: &mut RegionErrorNamingCtx,
) -> Option<RegionName> {
- let implicit_inputs = self.universal_regions.defining_ty.implicit_inputs();
- let argument_index = self.get_argument_index_for_region(mbcx.infcx.tcx, fr)?;
-
- let arg_ty =
- self.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(
- mbcx,
- fr,
- arg_ty,
- argument_index,
- renctx,
- ) {
+ 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 arg_ty = self.nonlexical_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)
+ {
return Some(region_name);
}
- self.give_name_if_we_cannot_match_hir_ty(mbcx, fr, arg_ty, renctx)
+ self.give_name_if_we_cannot_match_hir_ty(fr, arg_ty, renctx)
}
fn give_name_if_we_can_match_hir_ty_from_argument(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
needle_fr: RegionVid,
argument_ty: Ty<'tcx>,
argument_index: usize,
renctx: &mut RegionErrorNamingCtx,
) -> Option<RegionName> {
- let mir_hir_id = mbcx.infcx.tcx.hir().as_local_hir_id(mbcx.mir_def_id)?;
- let fn_decl = mbcx.infcx.tcx.hir().fn_decl_by_hir_id(mir_hir_id)?;
+ let mir_hir_id = self.infcx.tcx.hir().as_local_hir_id(self.mir_def_id)?;
+ let fn_decl = self.infcx.tcx.hir().fn_decl_by_hir_id(mir_hir_id)?;
let argument_hir_ty: &hir::Ty<'_> = fn_decl.inputs.get(argument_index)?;
match argument_hir_ty.kind {
// This indicates a variable with no type annotation, like
hir::TyKind::Infer => None,
_ => self.give_name_if_we_can_match_hir_ty(
- mbcx.infcx.tcx,
needle_fr,
argument_ty,
argument_hir_ty,
/// ```
fn give_name_if_we_cannot_match_hir_ty(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
needle_fr: RegionVid,
argument_ty: Ty<'tcx>,
renctx: &mut RegionErrorNamingCtx,
let counter = renctx.counter;
let mut highlight = RegionHighlightMode::default();
highlight.highlighting_region_vid(needle_fr, counter);
- let type_name = mbcx.infcx.extract_type_name(&argument_ty, Some(highlight)).0;
+ let type_name = self.infcx.extract_type_name(&argument_ty, Some(highlight)).0;
debug!(
"give_name_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}",
);
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.get_argument_index_for_region(mbcx.infcx.tcx, needle_fr)?;
- let (_, span) = self.get_argument_name_and_span_for_region(
- &mbcx.body,
- &mbcx.local_names,
+ 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(
+ &self.body,
+ &self.local_names,
argument_index,
);
/// to highlighting that closest type instead.
fn give_name_if_we_can_match_hir_ty(
&self,
- tcx: TyCtxt<'tcx>,
needle_fr: RegionVid,
argument_ty: Ty<'tcx>,
argument_hir_ty: &hir::Ty<'_>,
let region_name = renctx.synthesize_region_name();
// Just grab the first character, the `&`.
- let source_map = tcx.sess.source_map();
+ let source_map = self.infcx.tcx.sess.source_map();
let ampersand_span = source_map.start_point(hir_ty.span);
return Some(RegionName {
/// ```
fn give_name_if_anonymous_region_appears_in_upvars(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
fr: RegionVid,
renctx: &mut RegionErrorNamingCtx,
) -> Option<RegionName> {
- let upvar_index = self.get_upvar_index_for_region(mbcx.infcx.tcx, fr)?;
- let (upvar_name, upvar_span) =
- self.get_upvar_name_and_span_for_region(mbcx.infcx.tcx, &mbcx.upvars, upvar_index);
+ 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(
+ self.infcx.tcx,
+ &self.upvars,
+ upvar_index,
+ );
let region_name = renctx.synthesize_region_name();
Some(RegionName {
/// or be early bound (named, not in argument).
fn give_name_if_anonymous_region_appears_in_output(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
fr: RegionVid,
renctx: &mut RegionErrorNamingCtx,
) -> Option<RegionName> {
- let tcx = mbcx.infcx.tcx;
+ let tcx = self.infcx.tcx;
- let return_ty = self.universal_regions.unnormalized_output_ty;
+ let return_ty = self.nonlexical_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;
let mut highlight = RegionHighlightMode::default();
highlight.highlighting_region_vid(fr, renctx.counter);
- let type_name = mbcx.infcx.extract_type_name(&return_ty, Some(highlight)).0;
+ let type_name = self.infcx.extract_type_name(&return_ty, Some(highlight)).0;
- let mir_hir_id = tcx.hir().as_local_hir_id(mbcx.mir_def_id).expect("non-local mir");
+ let mir_hir_id = tcx.hir().as_local_hir_id(self.mir_def_id).expect("non-local mir");
let (return_span, mir_description) = match tcx.hir().get(mir_hir_id) {
hir::Node::Expr(hir::Expr {
kind: hir::ImplItemKind::Method(method_sig, _),
..
}) => (method_sig.decl.output.span(), ""),
- _ => (mbcx.body.span, ""),
+ _ => (self.body.span, ""),
};
Some(RegionName {
fn give_name_if_anonymous_region_appears_in_yield_ty(
&self,
- mbcx: &MirBorrowckCtxt<'_, 'tcx>,
fr: RegionVid,
renctx: &mut RegionErrorNamingCtx,
) -> Option<RegionName> {
// Note: generators from `async fn` yield `()`, so we don't have to
// worry about them here.
- let yield_ty = self.universal_regions.yield_ty?;
+ let yield_ty = self.nonlexical_regioncx.universal_regions.yield_ty?;
debug!("give_name_if_anonymous_region_appears_in_yield_ty: yield_ty = {:?}", yield_ty,);
- let tcx = mbcx.infcx.tcx;
+ let tcx = self.infcx.tcx;
if !tcx.any_free_region_meets(&yield_ty, |r| r.to_region_vid() == fr) {
return None;
let mut highlight = RegionHighlightMode::default();
highlight.highlighting_region_vid(fr, renctx.counter);
- let type_name = mbcx.infcx.extract_type_name(&yield_ty, Some(highlight)).0;
+ let type_name = self.infcx.extract_type_name(&yield_ty, Some(highlight)).0;
- let mir_hir_id = tcx.hir().as_local_hir_id(mbcx.mir_def_id).expect("non-local mir");
+ let mir_hir_id = tcx.hir().as_local_hir_id(self.mir_def_id).expect("non-local mir");
let yield_span = match tcx.hir().get(mir_hir_id) {
hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure(_, _, _, span, _), ..
}) => (tcx.sess.source_map().end_point(*span)),
- _ => mbcx.body.span,
+ _ => self.body.span,
};
debug!(