pub fn fixup_fragment_sets<'a, 'tcx>(this: &MoveData<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) {

    let mut fragments = this.fragments.borrow_mut();

    // Swap out contents of fragments so that we can modify the fields
    // without borrowing the common fragments.
    let mut unmoved = mem::replace(&mut fragments.unmoved_fragments, vec![]);
    let mut parents = mem::replace(&mut fragments.parents_of_fragments, vec![]);
    let mut moved = mem::replace(&mut fragments.moved_leaf_paths, vec![]);
    let mut assigned = mem::replace(&mut fragments.assigned_leaf_paths, vec![]);

    let path_lps = |mpis: &[MovePathIndex]| -> Vec<String> {
        mpis.iter().map(|mpi| format!("{:?}", this.path_loan_path(*mpi))).collect()
    };

    let frag_lps = |fs: &[Fragment]| -> Vec<String> {
        fs.iter().map(|f| f.loan_path_repr(this)).collect()
    };

    // First, filter out duplicates
    moved.sort();
    moved.dedup();
    debug!("fragments 1 moved: {:?}", path_lps(&moved[..]));

    assigned.sort();
    assigned.dedup();
    debug!("fragments 1 assigned: {:?}", path_lps(&assigned[..]));

    // Second, build parents from the moved and assigned.
    for m in &moved {
        let mut p = this.path_parent(*m);
        while p != InvalidMovePathIndex {
            parents.push(p);
            p = this.path_parent(p);
        }
    }
    for a in &assigned {
        let mut p = this.path_parent(*a);
        while p != InvalidMovePathIndex {
            parents.push(p);
            p = this.path_parent(p);
        }
    }

    parents.sort();
    parents.dedup();
    debug!("fragments 2 parents: {:?}", path_lps(&parents[..]));

    // Third, filter the moved and assigned fragments down to just the non-parents
    moved.retain(|f| non_member(*f, &parents[..]));
    debug!("fragments 3 moved: {:?}", path_lps(&moved[..]));

    assigned.retain(|f| non_member(*f, &parents[..]));
    debug!("fragments 3 assigned: {:?}", path_lps(&assigned[..]));

    // Fourth, build the leftover from the moved, assigned, and parents.
    for m in &moved {
        let lp = this.path_loan_path(*m);
        add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
    }
    for a in &assigned {
        let lp = this.path_loan_path(*a);
        add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
    }
    for p in &parents {
        let lp = this.path_loan_path(*p);
        add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
    }

    unmoved.sort();
    unmoved.dedup();
    debug!("fragments 4 unmoved: {:?}", frag_lps(&unmoved[..]));

    // Fifth, filter the leftover fragments down to its core.
    unmoved.retain(|f| match *f {
        AllButOneFrom(_) => true,
        Just(mpi) => non_member(mpi, &parents[..]) &&
            non_member(mpi, &moved[..]) &&
            non_member(mpi, &assigned[..])
    });
    debug!("fragments 5 unmoved: {:?}", frag_lps(&unmoved[..]));

    // Swap contents back in.
    fragments.unmoved_fragments = unmoved;
    fragments.parents_of_fragments = parents;
    fragments.moved_leaf_paths = moved;
    fragments.assigned_leaf_paths = assigned;

    return;

    fn non_member(elem: MovePathIndex, set: &[MovePathIndex]) -> bool {
        match set.binary_search(&elem) {
            Ok(_) => false,
            Err(_) => true,
        }
    }
}
/// Normalizes the fragment sets in `this`; i.e., removes duplicate entries, constructs the set of
/// parents, and constructs the left-over fragments.
///
/// Note: "left-over fragments" means paths that were not directly referenced in moves nor
/// assignments, but must nonetheless be tracked as potential drop obligations.
Normalizes the fragment sets in `this`; i.e., removes duplicate entries, constructs the set of
parents, and constructs the left-over fragments.

"left-over fragments" means paths that were not directly referenced in moves nor
assignments, but must nonetheless be tracked as potential drop obligations.
Normalizes the fragment sets in ` this ` ; i . e . removes duplicate entries constructs the set of parents and constructs the left - over fragments . " left - over fragments " means paths that were not directly referenced in moves nor assignments but must nonetheless be tracked as potential drop obligations .
pub fn fixup_fragment_sets<'a, 'tcx>(this: &MoveData<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
    let mut fragments = this.fragments.borrow_mut();
    // Swap out contents of fragments so that we can modify the fields
    // without borrowing the common fragments.
    let mut unmoved = mem::replace(&mut fragments.unmoved_fragments, vec![]);
    let mut parents = mem::replace(&mut fragments.parents_of_fragments, vec![]);
    let mut moved = mem::replace(&mut fragments.moved_leaf_paths, vec![]);
    let mut assigned = mem::replace(&mut fragments.assigned_leaf_paths, vec![]);
    let path_lps = |mpis: &[MovePathIndex]| -> Vec<String> {
        mpis.iter().map(|mpi| format!("{:?}", this.path_loan_path(*mpi))).collect()
    };
    let frag_lps = |fs: &[Fragment]| -> Vec<String> {
        fs.iter().map(|f| f.loan_path_repr(this)).collect()
    };
    // First, filter out duplicates
    moved.sort();
    moved.dedup();
    debug!("fragments 1 moved: {:?}", path_lps(&moved[..]));
    assigned.sort();
    assigned.dedup();
    debug!("fragments 1 assigned: {:?}", path_lps(&assigned[..]));
    // Second, build parents from the moved and assigned.
    for m in &moved {
        let mut p = this.path_parent(*m);
        while p != InvalidMovePathIndex {
            parents.push(p);
            p = this.path_parent(p);
        }
    }
    for a in &assigned {
        let mut p = this.path_parent(*a);
        while p != InvalidMovePathIndex {
            parents.push(p);
            p = this.path_parent(p);
        }
    }
    parents.sort();
    parents.dedup();
    debug!("fragments 2 parents: {:?}", path_lps(&parents[..]));
    // Third, filter the moved and assigned fragments down to just the non-parents
    moved.retain(|f| non_member(*f, &parents[..]));
    debug!("fragments 3 moved: {:?}", path_lps(&moved[..]));
    assigned.retain(|f| non_member(*f, &parents[..]));
    debug!("fragments 3 assigned: {:?}", path_lps(&assigned[..]));
    // Fourth, build the leftover from the moved, assigned, and parents.
    for m in &moved {
        let lp = this.path_loan_path(*m);
        add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
    }
    for a in &assigned {
        let lp = this.path_loan_path(*a);
        add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
    }
    for p in &parents {
        let lp = this.path_loan_path(*p);
        add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
    }
    unmoved.sort();
    unmoved.dedup();
    debug!("fragments 4 unmoved: {:?}", frag_lps(&unmoved[..]));
    // Fifth, filter the leftover fragments down to its core.
    unmoved.retain(|f| match *f {
        AllButOneFrom(_) => true,
        Just(mpi) => non_member(mpi, &parents[..]) &&
            non_member(mpi, &moved[..]) &&
            non_member(mpi, &assigned[..])
    });
    debug!("fragments 5 unmoved: {:?}", frag_lps(&unmoved[..]));
    // Swap contents back in.
    fragments.unmoved_fragments = unmoved;
    fragments.parents_of_fragments = parents;
    fragments.moved_leaf_paths = moved;
    fragments.assigned_leaf_paths = assigned;
    return;
    fn non_member(elem: MovePathIndex, set: &[MovePathIndex]) -> bool {
        match set.binary_search(&elem) {
            Ok(_) => false,
            Err(_) => true,
        }
    }
}
pub fn fixup_fragment_sets < ' a , ' tcx > ( this : & MoveData < ' tcx > , tcx : TyCtxt < ' a , ' tcx , ' tcx > ) { let mut fragments = this . fragments . borrow_mut ( ) ; // Swap out contents of fragments so that we can modify the fields // without borrowing the common fragments. let mut unmoved = mem :: replace ( & mut fragments . unmoved_fragments , vec ! [ ] ) ; let mut parents = mem :: replace ( & mut fragments . parents_of_fragments , vec ! [ ] ) ; let mut moved = mem :: replace ( & mut fragments . moved_leaf_paths , vec ! [ ] ) ; let mut assigned = mem :: replace ( & mut fragments . assigned_leaf_paths , vec ! [ ] ) ; let path_lps = | mpis : & [ MovePathIndex ] | -> Vec < String > { mpis . iter ( ) . map ( | mpi | format ! ( " " this path_loan_path ( mpi ) ) ) . collect ( ) } ; let frag_lps = | fs : & [ Fragment ] | -> Vec < String > { fs . iter ( ) . map ( | f | f . loan_path_repr ( this ) ) . collect ( ) } ; // First, filter out duplicates moved . sort ( ) ; moved . dedup ( ) ; debug ! ( " " path_lps ( moved [ ] ) ) ; assigned . sort ( ) ; assigned . dedup ( ) ; debug ! ( " " path_lps ( assigned [ ] ) ) ; // Second, build parents from the moved and assigned. for m in & moved { let mut p = this . path_parent ( * m ) ; while p != InvalidMovePathIndex { parents . push ( p ) ; p = this . path_parent ( p ) ; } } for a in & assigned { let mut p = this . path_parent ( * a ) ; while p != InvalidMovePathIndex { parents . push ( p ) ; p = this . path_parent ( p ) ; } } parents . sort ( ) ; parents . dedup ( ) ; debug ! ( " " path_lps ( parents [ ] ) ) ; // Third, filter the moved and assigned fragments down to just the non-parents moved . retain ( | f | non_member ( * f , & parents [ .. ] ) ) ; debug ! ( " " path_lps ( moved [ ] ) ) ; assigned . retain ( | f | non_member ( * f , & parents [ .. ] ) ) ; debug ! ( " " path_lps ( assigned [ ] ) ) ; // Fourth, build the leftover from the moved, assigned, and parents. for m in & moved { let lp = this . path_loan_path ( * m ) ; add_fragment_siblings ( this , tcx , & mut unmoved , lp , None ) ; } for a in & assigned { let lp = this . path_loan_path ( * a ) ; add_fragment_siblings ( this , tcx , & mut unmoved , lp , None ) ; } for p in & parents { let lp = this . path_loan_path ( * p ) ; add_fragment_siblings ( this , tcx , & mut unmoved , lp , None ) ; } unmoved . sort ( ) ; unmoved . dedup ( ) ; debug ! ( " " frag_lps ( unmoved [ ] ) ) ; // Fifth, filter the leftover fragments down to its core. unmoved . retain ( | f | match * f { AllButOneFrom ( _ ) => true , Just ( mpi ) => non_member ( mpi , & parents [ .. ] ) && non_member ( mpi , & moved [ .. ] ) && non_member ( mpi , & assigned [ .. ] ) } ) ; debug ! ( " " frag_lps ( unmoved [ ] ) ) ; // Swap contents back in. fragments . unmoved_fragments = unmoved ; fragments . parents_of_fragments = parents ; fragments . moved_leaf_paths = moved ; fragments . assigned_leaf_paths = assigned ; return ; fn non_member ( elem : MovePathIndex , set : & [ MovePathIndex ] ) -> bool { match set . binary_search ( & elem ) { Ok ( _ ) => false , Err ( _ ) => true , } } }
Normalizes the fragment sets in `this`; i.e., removes duplicate entries, constructs the set of
parents, and constructs the left-over fragments.
Normalizes the fragment sets in ` this ` ; i . e . removes duplicate entries constructs the set of parents and constructs the left - over fragments .
this
&MoveData<'tcx>
tcx
TyCtxt<'a, 'tcx, 'tcx>
this
&MoveData<'tcx>
tcx
TyCtxt<'a, 'tcx, 'tcx>