fn adjust_upvar_borrow_kind(&mut self, upvar_id: ty::UpvarId, kind: ty::BorrowKind) {
        let upvar_capture = self.adjust_upvar_captures
            .get(&upvar_id)
            .cloned()
            .unwrap_or_else(|| self.fcx.tables.borrow().upvar_capture(upvar_id));
        debug!(
            "adjust_upvar_borrow_kind(upvar_id={:?}, upvar_capture={:?}, kind={:?})",
            upvar_id,
            upvar_capture,
            kind
        );

        match upvar_capture {
            ty::UpvarCapture::ByValue => {
                // Upvar is already by-value, the strongest criteria.
            }
            ty::UpvarCapture::ByRef(mut upvar_borrow) => {
                match (upvar_borrow.kind, kind) {
                    // Take RHS:
                    (ty::ImmBorrow, ty::UniqueImmBorrow) |
                    (ty::ImmBorrow, ty::MutBorrow) |
                    (ty::UniqueImmBorrow, ty::MutBorrow) => {
                        upvar_borrow.kind = kind;
                        self.adjust_upvar_captures
                            .insert(upvar_id, ty::UpvarCapture::ByRef(upvar_borrow));
                    }
                    // Take LHS:
                    (ty::ImmBorrow, ty::ImmBorrow) |
                    (ty::UniqueImmBorrow, ty::ImmBorrow) |
                    (ty::UniqueImmBorrow, ty::UniqueImmBorrow) |
                    (ty::MutBorrow, _) => {}
                }
            }
        }
    }
/// We infer the borrow_kind with which to borrow upvars in a stack closure.
/// The borrow_kind basically follows a lattice of `imm < unique-imm < mut`,
/// moving from left to right as needed (but never right to left).
/// Here the argument `mutbl` is the borrow_kind that is required by
/// some particular use.
We infer the borrow_kind with which to borrow upvars in a stack closure.
The borrow_kind basically follows a lattice of `imm < unique-imm < mut`,
moving from left to right as needed (but never right to left).
Here the argument `mutbl` is the borrow_kind that is required by
some particular use.
We infer the borrow_kind with which to borrow upvars in a stack closure . The borrow_kind basically follows a lattice of ` imm < unique - imm < mut ` moving from left to right as needed ( but never right to left ) . Here the argument ` mutbl ` is the borrow_kind that is required by some particular use .
fn adjust_upvar_borrow_kind(&mut self, upvar_id: ty::UpvarId, kind: ty::BorrowKind) {
        let upvar_capture = self.adjust_upvar_captures
            .get(&upvar_id)
            .cloned()
            .unwrap_or_else(|| self.fcx.tables.borrow().upvar_capture(upvar_id));
        debug!(
            "adjust_upvar_borrow_kind(upvar_id={:?}, upvar_capture={:?}, kind={:?})",
            upvar_id,
            upvar_capture,
            kind
        );
        match upvar_capture {
            ty::UpvarCapture::ByValue => {
                // Upvar is already by-value, the strongest criteria.
            }
            ty::UpvarCapture::ByRef(mut upvar_borrow) => {
                match (upvar_borrow.kind, kind) {
                    // Take RHS:
                    (ty::ImmBorrow, ty::UniqueImmBorrow) |
                    (ty::ImmBorrow, ty::MutBorrow) |
                    (ty::UniqueImmBorrow, ty::MutBorrow) => {
                        upvar_borrow.kind = kind;
                        self.adjust_upvar_captures
                            .insert(upvar_id, ty::UpvarCapture::ByRef(upvar_borrow));
                    }
                    // Take LHS:
                    (ty::ImmBorrow, ty::ImmBorrow) |
                    (ty::UniqueImmBorrow, ty::ImmBorrow) |
                    (ty::UniqueImmBorrow, ty::UniqueImmBorrow) |
                    (ty::MutBorrow, _) => {}
                }
            }
        }
    }
fn adjust_upvar_borrow_kind ( & mut self , upvar_id : ty :: UpvarId , kind : ty :: BorrowKind ) { let upvar_capture = self . adjust_upvar_captures . get ( & upvar_id ) . cloned ( ) . unwrap_or_else ( | | self . fcx . tables . borrow ( ) . upvar_capture ( upvar_id ) ) ; debug ! ( " " upvar_id upvar_capture kind ) ; match upvar_capture { ty :: UpvarCapture :: ByValue => { // Upvar is already by-value, the strongest criteria. } ty :: UpvarCapture :: ByRef ( mut upvar_borrow ) => { match ( upvar_borrow . kind , kind ) { // Take RHS: ( ty :: ImmBorrow , ty :: UniqueImmBorrow ) | ( ty :: ImmBorrow , ty :: MutBorrow ) | ( ty :: UniqueImmBorrow , ty :: MutBorrow ) => { upvar_borrow . kind = kind ; self . adjust_upvar_captures . insert ( upvar_id , ty :: UpvarCapture :: ByRef ( upvar_borrow ) ) ; } // Take LHS: ( ty :: ImmBorrow , ty :: ImmBorrow ) | ( ty :: UniqueImmBorrow , ty :: ImmBorrow ) | ( ty :: UniqueImmBorrow , ty :: UniqueImmBorrow ) | ( ty :: MutBorrow , _ ) => { } } } } }
We infer the borrow_kind with which to borrow upvars in a stack closure.
We infer the borrow_kind with which to borrow upvars in a stack closure .
&mut self
upvar_id
ty::UpvarId
kind
ty::BorrowKind