/// Check for arguments appearing in the (closure) return type. It
/// must be a closure since, in a free fn, such an argument would
/// have to either also appear in an argument (if using elision)
/// or be early bound (named, not in argument).
Check for arguments appearing in the (closure) return type. It
must be a closure since, in a free fn, such an argument would
have to either also appear in an argument (if using elision)
or be early bound (named, not in argument).
Check for arguments appearing in the ( closure ) return type . It must be a closure since in a free fn such an argument would have to either also appear in an argument ( if using elision ) or be early bound ( named not in argument ) .
fn give_name_if_anonymous_region_appears_in_output(
        &self,
        infcx: &InferCtxt<'_, '_, 'tcx>,
        mir: &Mir<'tcx>,
        mir_def_id: DefId,
        fr: RegionVid,
        counter: &mut usize,
        diag: &mut DiagnosticBuilder<'_>,
    ) -> Option<InternedString> {
        let tcx = infcx.tcx;
        let return_ty = self.universal_regions.unnormalized_output_ty;
        debug!(
            "give_name_if_anonymous_region_appears_in_output: return_ty = {:?}",
            return_ty
        );
        if !infcx.tcx.any_free_region_meets(&return_ty, |r| r.to_region_vid() == fr) {
            return None;
        }
        let type_name = with_highlight_region(fr, *counter, || {
            infcx.extract_type_name(&return_ty)
        });
        let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir");
        let (return_span, mir_description) = if let hir::ExprKind::Closure(_, _, _, span, gen_move)
            = tcx.hir.expect_expr(mir_node_id).node
        {
            (
                tcx.sess.source_map().end_point(span),
                if gen_move.is_some() { " of generator" } else { " of closure" }
            )
        } else {
            // unreachable?
            (mir.span, "")
        };
        diag.span_label(
            return_span,
            format!("return type{} is {}", mir_description, type_name),
        );
        // This counter value will already have been used, so this function will increment it
        // so the next value will be used next and return the region name that would have been
        // used.
        Some(self.synthesize_region_name(counter))
    }
fn give_name_if_anonymous_region_appears_in_output ( & self , infcx : & InferCtxt < ' _ , ' _ , ' tcx > , mir : & Mir < ' tcx > , mir_def_id : DefId , fr : RegionVid , counter : & mut usize , diag : & mut DiagnosticBuilder < ' _ > , ) -> Option < InternedString > { let tcx = infcx . tcx ; let return_ty = self . universal_regions . unnormalized_output_ty ; debug ! ( " " return_ty ) ; if ! infcx . tcx . any_free_region_meets ( & return_ty , | r | r . to_region_vid ( ) == fr ) { return None ; } let type_name = with_highlight_region ( fr , * counter , | | { infcx . extract_type_name ( & return_ty ) } ) ; let mir_node_id = tcx . hir . as_local_node_id ( mir_def_id ) . expect ( " " ) ; let ( return_span , mir_description ) = if let hir :: ExprKind :: Closure ( _ , _ , _ , span , gen_move ) = tcx . hir . expect_expr ( mir_node_id ) . node { ( tcx . sess . source_map ( ) . end_point ( span ) , if gen_move . is_some ( ) { " " } else { " " } ) } else { // unreachable? ( mir . span , " " ) } ; diag . span_label ( return_span , format ! ( " " mir_description type_name ) , ) ; // This counter value will already have been used, so this function will increment it // so the next value will be used next and return the region name that would have been // used. Some ( self . synthesize_region_name ( counter ) ) }
Check for arguments appearing in the (closure) return type.
Check for arguments appearing in the ( closure ) return type .
&self
infcx
&InferCtxt<'_, '_, 'tcx>
mir
&Mir<'tcx>
mir_def_id
DefId
fr
RegionVid
counter
&mut usize
diag
&mut DiagnosticBuilder<'_>