fn compute_cnum_map(tcx: TyCtxt,
                        prev_cnums: &[(u32, String, CrateDisambiguator)])
                        -> IndexVec<CrateNum, Option<CrateNum>>
    {
        tcx.dep_graph.with_ignore(|| {
            let current_cnums = tcx.all_crate_nums(LOCAL_CRATE).iter().map(|&cnum| {
                let crate_name = tcx.original_crate_name(cnum)
                                    .as_str()
                                    .to_string();
                let crate_disambiguator = tcx.crate_disambiguator(cnum);
                ((crate_name, crate_disambiguator), cnum)
            }).collect::<FxHashMap<_,_>>();

            let map_size = prev_cnums.iter()
                                    .map(|&(cnum, ..)| cnum)
                                    .max()
                                    .unwrap_or(0) + 1;
            let mut map = IndexVec::new();
            map.resize(map_size as usize, None);

            for &(prev_cnum, ref crate_name, crate_disambiguator) in prev_cnums {
                let key = (crate_name.clone(), crate_disambiguator);
                map[CrateNum::from_u32(prev_cnum)] = current_cnums.get(&key).cloned();
            }

            map[LOCAL_CRATE] = Some(LOCAL_CRATE);
            map
        })
    }
// This function builds mapping from previous-session-CrateNum to
// current-session-CrateNum. There might be CrateNums from the previous
// Session that don't occur in the current one. For these, the mapping
// maps to None.
This function builds mapping from previous-session-CrateNum to
current-session-CrateNum. There might be CrateNums from the previous
Session that don't occur in the current one. For these, the mapping
maps to None.
This function builds mapping from previous - session - CrateNum to current - session - CrateNum . There might be CrateNums from the previous Session that don ' t occur in the current one . For these the mapping maps to None .
fn compute_cnum_map(tcx: TyCtxt,
                        prev_cnums: &[(u32, String, CrateDisambiguator)])
                        -> IndexVec<CrateNum, Option<CrateNum>>
    {
        tcx.dep_graph.with_ignore(|| {
            let current_cnums = tcx.all_crate_nums(LOCAL_CRATE).iter().map(|&cnum| {
                let crate_name = tcx.original_crate_name(cnum)
                                    .as_str()
                                    .to_string();
                let crate_disambiguator = tcx.crate_disambiguator(cnum);
                ((crate_name, crate_disambiguator), cnum)
            }).collect::<FxHashMap<_,_>>();
            let map_size = prev_cnums.iter()
                                    .map(|&(cnum, ..)| cnum)
                                    .max()
                                    .unwrap_or(0) + 1;
            let mut map = IndexVec::new();
            map.resize(map_size as usize, None);
            for &(prev_cnum, ref crate_name, crate_disambiguator) in prev_cnums {
                let key = (crate_name.clone(), crate_disambiguator);
                map[CrateNum::from_u32(prev_cnum)] = current_cnums.get(&key).cloned();
            }
            map[LOCAL_CRATE] = Some(LOCAL_CRATE);
            map
        })
    }
fn compute_cnum_map ( tcx : TyCtxt , prev_cnums : & [ ( u32 , String , CrateDisambiguator ) ] ) -> IndexVec < CrateNum , Option < CrateNum > > { tcx . dep_graph . with_ignore ( | | { let current_cnums = tcx . all_crate_nums ( LOCAL_CRATE ) . iter ( ) . map ( | & cnum | { let crate_name = tcx . original_crate_name ( cnum ) . as_str ( ) . to_string ( ) ; let crate_disambiguator = tcx . crate_disambiguator ( cnum ) ; ( ( crate_name , crate_disambiguator ) , cnum ) } ) . collect :: < FxHashMap < _ , _ > > ( ) ; let map_size = prev_cnums . iter ( ) . map ( | & ( cnum , .. ) | cnum ) . max ( ) . unwrap_or ( 0 ) + 1 ; let mut map = IndexVec :: new ( ) ; map . resize ( map_size as usize , None ) ; for & ( prev_cnum , ref crate_name , crate_disambiguator ) in prev_cnums { let key = ( crate_name . clone ( ) , crate_disambiguator ) ; map [ CrateNum :: from_u32 ( prev_cnum ) ] = current_cnums . get ( & key ) . cloned ( ) ; } map [ LOCAL_CRATE ] = Some ( LOCAL_CRATE ) ; map } ) }
This function builds mapping from previous-session-CrateNum to
current-session-CrateNum.
This function builds mapping from previous - session - CrateNum to current - session - CrateNum .
tcx
TyCtxt
prev_cnums
&[(u32, String, CrateDisambiguator)]