fn report_fnmut_error(
        &self,
        errci: &ErrorConstraintInfo,
        kind: ReturnConstraint,
    ) -> DiagnosticBuilder<'tcx> {
        let ErrorConstraintInfo { outlived_fr, span, .. } = errci;

        let mut diag = self
            .infcx
            .tcx
            .sess
            .struct_span_err(*span, "captured variable cannot escape `FnMut` closure body");

        let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty;
        if let ty::Opaque(def_id, _) = *output_ty.kind() {
            output_ty = self.infcx.tcx.type_of(def_id)
        };

        debug!("report_fnmut_error: output_ty={:?}", output_ty);

        let message = match output_ty.kind() {
            ty::Closure(_, _) => {
                "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) => {
                "returns an `async` block that contains a reference to a captured variable, which then \
                 escapes the closure body"
            }
            _ => "returns a reference to a captured variable which escapes the closure body",
        };

        diag.span_label(*span, message);

        // FIXME(project-rfc-2229#48): This should store a captured_place not a hir id
        if let ReturnConstraint::ClosureUpvar(upvar) = kind {
            let def_id = match self.regioncx.universal_regions().defining_ty {
                DefiningTy::Closure(def_id, _) => def_id,
                ty => bug!("unexpected DefiningTy {:?}", ty),
            };

            let upvar_def_span = self.infcx.tcx.hir().span(upvar);
            let upvar_span = self.infcx.tcx.upvars_mentioned(def_id).unwrap()[&upvar].span;
            diag.span_label(upvar_def_span, "variable defined here");
            diag.span_label(upvar_span, "variable captured here");
        }

        if let Some(fr_span) = self.give_region_a_name(*outlived_fr).unwrap().span() {
            diag.span_label(fr_span, "inferred to be a `FnMut` closure");
        }

        diag.note(
            "`FnMut` closures only have access to their captured variables while they are \
             executing...",
        );
        diag.note("...therefore, they cannot allow references to captured variables to escape");

        diag
    }
/// Report a specialized error when `FnMut` closures return a reference to a captured variable.
/// This function expects `fr` to be local and `outlived_fr` to not be local.
///
/// ```text
/// error: captured variable cannot escape `FnMut` closure body
///   --> $DIR/issue-53040.rs:15:8
///    |
/// LL |     || &mut v;
///    |     -- ^^^^^^ creates a reference to a captured variable which escapes the closure body
///    |     |
///    |     inferred to be a `FnMut` closure
///    |
///    = note: `FnMut` closures only have access to their captured variables while they are
///            executing...
///    = note: ...therefore, returned references to captured variables will escape the closure
/// ```
Report a specialized error when `FnMut` closures return a reference to a captured variable.
This function expects `fr` to be local and `outlived_fr` to not be local.


Report a specialized error when ` FnMut ` closures return a reference to a captured variable . This function expects ` fr ` to be local and ` outlived_fr ` to not be local .
fn report_fnmut_error(
        &self,
        errci: &ErrorConstraintInfo,
        kind: ReturnConstraint,
    ) -> DiagnosticBuilder<'tcx> {
        let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
        let mut diag = self
            .infcx
            .tcx
            .sess
            .struct_span_err(*span, "captured variable cannot escape `FnMut` closure body");
        let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty;
        if let ty::Opaque(def_id, _) = *output_ty.kind() {
            output_ty = self.infcx.tcx.type_of(def_id)
        };
        debug!("report_fnmut_error: output_ty={:?}", output_ty);
        let message = match output_ty.kind() {
            ty::Closure(_, _) => {
                "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) => {
                "returns an `async` block that contains a reference to a captured variable, which then \
                 escapes the closure body"
            }
            _ => "returns a reference to a captured variable which escapes the closure body",
        };
        diag.span_label(*span, message);
        // FIXME(project-rfc-2229#48): This should store a captured_place not a hir id
        if let ReturnConstraint::ClosureUpvar(upvar) = kind {
            let def_id = match self.regioncx.universal_regions().defining_ty {
                DefiningTy::Closure(def_id, _) => def_id,
                ty => bug!("unexpected DefiningTy {:?}", ty),
            };
            let upvar_def_span = self.infcx.tcx.hir().span(upvar);
            let upvar_span = self.infcx.tcx.upvars_mentioned(def_id).unwrap()[&upvar].span;
            diag.span_label(upvar_def_span, "variable defined here");
            diag.span_label(upvar_span, "variable captured here");
        }
        if let Some(fr_span) = self.give_region_a_name(*outlived_fr).unwrap().span() {
            diag.span_label(fr_span, "inferred to be a `FnMut` closure");
        }
        diag.note(
            "`FnMut` closures only have access to their captured variables while they are \
             executing...",
        );
        diag.note("...therefore, they cannot allow references to captured variables to escape");
        diag
    }
fn report_fnmut_error ( & self , errci : & ErrorConstraintInfo , kind : ReturnConstraint , ) -> DiagnosticBuilder < ' tcx > { let ErrorConstraintInfo { outlived_fr , span , .. } = errci ; let mut diag = self . infcx . tcx . sess . struct_span_err ( * span , " " ) ; let mut output_ty = self . regioncx . universal_regions ( ) . unnormalized_output_ty ; if let ty :: Opaque ( def_id , _ ) = * output_ty . kind ( ) { output_ty = self . infcx . tcx . type_of ( def_id ) } ; debug ! ( " " output_ty ) ; let message = match output_ty . kind ( ) { ty :: Closure ( _ , _ ) => { " \
 " } ty :: Adt ( def , _ ) if self . infcx . tcx . is_diagnostic_item ( sym :: gen_future , def . did ) => { " \
 " } _ => " " , } ; diag . span_label ( * span , message ) ; // FIXME(project-rfc-2229#48): This should store a captured_place not a hir id if let ReturnConstraint :: ClosureUpvar ( upvar ) = kind { let def_id = match self . regioncx . universal_regions ( ) . defining_ty { DefiningTy :: Closure ( def_id , _ ) => def_id , ty => bug ! ( " " ty ) , } ; let upvar_def_span = self . infcx . tcx . hir ( ) . span ( upvar ) ; let upvar_span = self . infcx . tcx . upvars_mentioned ( def_id ) . unwrap ( ) [ & upvar ] . span ; diag . span_label ( upvar_def_span , " " ) ; diag . span_label ( upvar_span , " " ) ; } if let Some ( fr_span ) = self . give_region_a_name ( * outlived_fr ) . unwrap ( ) . span ( ) { diag . span_label ( fr_span , " " ) ; } diag . note ( " \
 " , ) ; diag . note ( " " ) ; diag }
Report a specialized error when `FnMut` closures return a reference to a captured variable.
Report a specialized error when ` FnMut ` closures return a reference to a captured variable .
&self
errci
&ErrorConstraintInfo
kind
ReturnConstraint
&self
errci
&ErrorConstraintInfo
kind
ReturnConstraint