//! Error reporting machinery for lifetime errors.
-use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported};
+use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_infer::infer::{
error_reporting::nice_region_error::NiceRegionError,
error_reporting::unexpected_hidden_region_diagnostic, NllRegionVariableOrigin,
/// Returns `true` if a closure is inferred to be an `FnMut` closure.
fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
- if let Some(ty::ReFree(free_region)) = self.to_error_region(fr).as_deref() {
- if let ty::BoundRegionKind::BrEnv = free_region.bound_region {
- if let DefiningTy::Closure(_, substs) =
- self.regioncx.universal_regions().defining_ty
- {
- return substs.as_closure().kind() == ty::ClosureKind::FnMut;
- }
- }
+ if let Some(ty::ReFree(free_region)) = self.to_error_region(fr).as_deref()
+ && let ty::BoundRegionKind::BrEnv = free_region.bound_region
+ && let DefiningTy::Closure(_, substs) = self.regioncx.universal_regions().defining_ty
+ {
+ return substs.as_closure().kind() == ty::ClosureKind::FnMut;
}
false
ty::Adt(adt, substs) => {
let generic_arg = substs[param_index as usize];
let identity_substs =
- InternalSubsts::identity_for_item(self.infcx.tcx, adt.did);
- let base_ty = self.infcx.tcx.mk_adt(adt, identity_substs);
+ InternalSubsts::identity_for_item(self.infcx.tcx, adt.did());
+ let base_ty = self.infcx.tcx.mk_adt(*adt, identity_substs);
let base_generic_arg = identity_substs[param_index as usize];
let adt_desc = adt.descr();
&self,
errci: &ErrorConstraintInfo,
kind: ReturnConstraint,
- ) -> DiagnosticBuilder<'tcx, ErrorReported> {
+ ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
let mut diag = self
"returns a closure that contains a reference to a captured variable, which then \
escapes the closure body"
}
- ty::Adt(def, _) if self.infcx.tcx.is_diagnostic_item(sym::gen_future, def.did) => {
+ ty::Adt(def, _) if self.infcx.tcx.is_diagnostic_item(sym::gen_future, def.did()) => {
"returns an `async` block that contains a reference to a captured variable, which then \
escapes the closure body"
}
fn report_escaping_data_error(
&self,
errci: &ErrorConstraintInfo,
- ) -> DiagnosticBuilder<'tcx, ErrorReported> {
+ ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ErrorConstraintInfo { span, category, .. } = errci;
let fr_name_and_span = self.regioncx.get_var_name_and_span_for_region(
fn report_general_error(
&self,
errci: &ErrorConstraintInfo,
- ) -> DiagnosticBuilder<'tcx, ErrorReported> {
+ ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ErrorConstraintInfo {
fr,
fr_is_local,