// Returns a list of `ClosureUpvar`s for each upvar.
Returns a list of `ClosureUpvar`s for each upvar.
Returns a list of ` ClosureUpvar ` s for each upvar .
fn final_upvar_tys(&mut self, closure_id: ast::NodeId) -> Vec<Ty<'tcx>> {
        // Presently an unboxed closure type cannot "escape" out of a
        // function, so we will only encounter ones that originated in the
        // local crate or were inlined into it along with some function.
        // This may change if abstract return types of some sort are
        // implemented.
        let tcx = self.fcx.tcx();
        tcx.with_freevars(closure_id, |freevars| {
            freevars.iter()
                    .map(|freevar| {
                        let freevar_def_id = freevar.def.def_id();
                        let freevar_ty = self.fcx.node_ty(freevar_def_id.node);
                        let upvar_id = ty::UpvarId {
                            var_id: freevar_def_id.node,
                            closure_expr_id: closure_id
                        };
                        let capture = self.fcx.infcx().upvar_capture(upvar_id).unwrap();
                        debug!("freevar_def_id={:?} freevar_ty={:?} capture={:?}",
                               freevar_def_id, freevar_ty, capture);
                        match capture {
                            ty::UpvarCapture::ByValue => freevar_ty,
                            ty::UpvarCapture::ByRef(borrow) =>
                                tcx.mk_ref(tcx.mk_region(borrow.region),
                                           ty::TypeAndMut {
                                               ty: freevar_ty,
                                               mutbl: borrow.kind.to_mutbl_lossy(),
                                           }),
                        }
                    })
                    .collect()
            })
    }
fn final_upvar_tys ( & mut self , closure_id : ast :: NodeId ) -> Vec < Ty < ' tcx > > { // Presently an unboxed closure type cannot "escape" out of a // function, so we will only encounter ones that originated in the // local crate or were inlined into it along with some function. // This may change if abstract return types of some sort are // implemented. let tcx = self . fcx . tcx ( ) ; tcx . with_freevars ( closure_id , | freevars | { freevars . iter ( ) . map ( | freevar | { let freevar_def_id = freevar . def . def_id ( ) ; let freevar_ty = self . fcx . node_ty ( freevar_def_id . node ) ; let upvar_id = ty :: UpvarId { var_id : freevar_def_id . node , closure_expr_id : closure_id } ; let capture = self . fcx . infcx ( ) . upvar_capture ( upvar_id ) . unwrap ( ) ; debug ! ( " " freevar_def_id freevar_ty capture ) ; match capture { ty :: UpvarCapture :: ByValue => freevar_ty , ty :: UpvarCapture :: ByRef ( borrow ) => tcx . mk_ref ( tcx . mk_region ( borrow . region ) , ty :: TypeAndMut { ty : freevar_ty , mutbl : borrow . kind . to_mutbl_lossy ( ) , } ) , } } ) . collect ( ) } ) }
Returns a list of `ClosureUpvar`s for each upvar.
Returns a list of ` ClosureUpvar ` s for each upvar .
&mut self
closure_id
ast::NodeId