fn add_fragment_siblings<'a, 'tcx>(this: &MoveData<'tcx>,
                                   tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                   gathered_fragments: &mut Vec<Fragment>,
                                   lp: Rc<LoanPath<'tcx>>,
                                   origin_id: Option<ast::NodeId>) {
    match lp.kind {
        LpVar(_) | LpUpvar(..) => {} // Local variables have no siblings.

        // Consuming a downcast is like consuming the original value, so propage inward.
        LpDowncast(ref loan_parent, _) => {
            add_fragment_siblings(this, tcx, gathered_fragments, loan_parent.clone(), origin_id);
        }

        // *LV for Unique consumes the contents of the box (at
        // least when it is non-copy...), so propagate inward.
        LpExtend(ref loan_parent, _, LpDeref(mc::Unique)) => {
            add_fragment_siblings(this, tcx, gathered_fragments, loan_parent.clone(), origin_id);
        }

        // *LV for unsafe and borrowed pointers do not consume their loan path, so stop here.
        LpExtend(.., LpDeref(mc::UnsafePtr(..)))   |
        LpExtend(.., LpDeref(mc::Implicit(..)))    |
        LpExtend(.., LpDeref(mc::BorrowedPtr(..))) => {}

        // FIXME (pnkfelix): LV[j] should be tracked, at least in the
        // sense of we will track the remaining drop obligation of the
        // rest of the array.
        //
        // Well, either that or LV[j] should be made illegal.
        // But even then, we will need to deal with destructuring
        // bind.
        //
        // Anyway, for now: LV[j] is not tracked precisely
        LpExtend(.., LpInterior(_, InteriorElement(..))) => {
            let mp = this.move_path(tcx, lp.clone());
            gathered_fragments.push(AllButOneFrom(mp));
        }

        // field access LV.x and tuple access LV#k are the cases
        // we are interested in
        LpExtend(ref loan_parent, mc,
                 LpInterior(_, InteriorField(ref field_name))) => {
            let enum_variant_info = match loan_parent.kind {
                LpDowncast(ref loan_parent_2, variant_def_id) =>
                    Some((variant_def_id, loan_parent_2.clone())),
                LpExtend(..) | LpVar(..) | LpUpvar(..) =>
                    None,
            };
            add_fragment_siblings_for_extension(
                this,
                tcx,
                gathered_fragments,
                loan_parent, mc, field_name, &lp, origin_id, enum_variant_info);
        }
    }
}
/// Adds all of the precisely-tracked siblings of `lp` as potential move paths of interest. For
/// example, if `lp` represents `s.x.j`, then adds moves paths for `s.x.i` and `s.x.k`, the
/// siblings of `s.x.j`.
Adds all of the precisely-tracked siblings of `lp` as potential move paths of interest.
Adds all of the precisely - tracked siblings of ` lp ` as potential move paths of interest .
fn add_fragment_siblings<'a, 'tcx>(this: &MoveData<'tcx>,
                                   tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                   gathered_fragments: &mut Vec<Fragment>,
                                   lp: Rc<LoanPath<'tcx>>,
                                   origin_id: Option<ast::NodeId>) {
    match lp.kind {
        LpVar(_) | LpUpvar(..) => {} // Local variables have no siblings.
        // Consuming a downcast is like consuming the original value, so propage inward.
        LpDowncast(ref loan_parent, _) => {
            add_fragment_siblings(this, tcx, gathered_fragments, loan_parent.clone(), origin_id);
        }
        // *LV for Unique consumes the contents of the box (at
        // least when it is non-copy...), so propagate inward.
        LpExtend(ref loan_parent, _, LpDeref(mc::Unique)) => {
            add_fragment_siblings(this, tcx, gathered_fragments, loan_parent.clone(), origin_id);
        }
        // *LV for unsafe and borrowed pointers do not consume their loan path, so stop here.
        LpExtend(.., LpDeref(mc::UnsafePtr(..)))   |
        LpExtend(.., LpDeref(mc::Implicit(..)))    |
        LpExtend(.., LpDeref(mc::BorrowedPtr(..))) => {}
        // FIXME (pnkfelix): LV[j] should be tracked, at least in the
        // sense of we will track the remaining drop obligation of the
        // rest of the array.
        //
        // Well, either that or LV[j] should be made illegal.
        // But even then, we will need to deal with destructuring
        // bind.
        //
        // Anyway, for now: LV[j] is not tracked precisely
        LpExtend(.., LpInterior(_, InteriorElement(..))) => {
            let mp = this.move_path(tcx, lp.clone());
            gathered_fragments.push(AllButOneFrom(mp));
        }
        // field access LV.x and tuple access LV#k are the cases
        // we are interested in
        LpExtend(ref loan_parent, mc,
                 LpInterior(_, InteriorField(ref field_name))) => {
            let enum_variant_info = match loan_parent.kind {
                LpDowncast(ref loan_parent_2, variant_def_id) =>
                    Some((variant_def_id, loan_parent_2.clone())),
                LpExtend(..) | LpVar(..) | LpUpvar(..) =>
                    None,
            };
            add_fragment_siblings_for_extension(
                this,
                tcx,
                gathered_fragments,
                loan_parent, mc, field_name, &lp, origin_id, enum_variant_info);
        }
    }
}
fn add_fragment_siblings < ' a , ' tcx > ( this : & MoveData < ' tcx > , tcx : TyCtxt < ' a , ' tcx , ' tcx > , gathered_fragments : & mut Vec < Fragment > , lp : Rc < LoanPath < ' tcx > > , origin_id : Option < ast :: NodeId > ) { match lp . kind { LpVar ( _ ) | LpUpvar ( .. ) => { } // Local variables have no siblings. // Consuming a downcast is like consuming the original value, so propage inward. LpDowncast ( ref loan_parent , _ ) => { add_fragment_siblings ( this , tcx , gathered_fragments , loan_parent . clone ( ) , origin_id ) ; } // *LV for Unique consumes the contents of the box (at // least when it is non-copy...), so propagate inward. LpExtend ( ref loan_parent , _ , LpDeref ( mc :: Unique ) ) => { add_fragment_siblings ( this , tcx , gathered_fragments , loan_parent . clone ( ) , origin_id ) ; } // *LV for unsafe and borrowed pointers do not consume their loan path, so stop here. LpExtend ( .. , LpDeref ( mc :: UnsafePtr ( .. ) ) ) | LpExtend ( .. , LpDeref ( mc :: Implicit ( .. ) ) ) | LpExtend ( .. , LpDeref ( mc :: BorrowedPtr ( .. ) ) ) => { } // FIXME (pnkfelix): LV[j] should be tracked, at least in the // sense of we will track the remaining drop obligation of the // rest of the array. // // Well, either that or LV[j] should be made illegal. // But even then, we will need to deal with destructuring // bind. // // Anyway, for now: LV[j] is not tracked precisely LpExtend ( .. , LpInterior ( _ , InteriorElement ( .. ) ) ) => { let mp = this . move_path ( tcx , lp . clone ( ) ) ; gathered_fragments . push ( AllButOneFrom ( mp ) ) ; } // field access LV.x and tuple access LV#k are the cases // we are interested in LpExtend ( ref loan_parent , mc , LpInterior ( _ , InteriorField ( ref field_name ) ) ) => { let enum_variant_info = match loan_parent . kind { LpDowncast ( ref loan_parent_2 , variant_def_id ) => Some ( ( variant_def_id , loan_parent_2 . clone ( ) ) ) , LpExtend ( .. ) | LpVar ( .. ) | LpUpvar ( .. ) => None , } ; add_fragment_siblings_for_extension ( this , tcx , gathered_fragments , loan_parent , mc , field_name , & lp , origin_id , enum_variant_info ) ; } } }
Adds all of the precisely-tracked siblings of `lp` as potential move paths of interest.
Adds all of the precisely - tracked siblings of ` lp ` as potential move paths of interest .
this
&MoveData<'tcx>
tcx
TyCtxt<'a, 'tcx, 'tcx>
gathered_fragments
&mut Vec<Fragment>
lp
Rc<LoanPath<'tcx>>
origin_id
Option<ast::NodeId>
this
&MoveData<'tcx>
tcx
TyCtxt<'a, 'tcx, 'tcx>
gathered_fragments
&mut Vec<Fragment>
lp
Rc<LoanPath<'tcx>>
origin_id
Option<ast::NodeId>