/// Helper for looking things up in the various maps that are populated during
/// typeck::collect (e.g., `cx.impl_or_trait_items`, `cx.tcache`, etc).  All of
/// these share the pattern that if the id is local, it should have been loaded
/// into the map by the `typeck::collect` phase.  If the def-id is external,
/// then we have to go consult the crate loading code (and cache the result for
/// the future).
Helper for looking things up in the various maps that are populated during
typeck::collect .  All of
these share the pattern that if the id is local, it should have been loaded
into the map by the `typeck::collect` phase.  If the def-id is external,
then we have to go consult the crate loading code (and cache the result for
the future).
Helper for looking things up in the various maps that are populated during typeck :: collect . All of these share the pattern that if the id is local it should have been loaded into the map by the ` typeck :: collect ` phase . If the def - id is external then we have to go consult the crate loading code ( and cache the result for the future ) .
fn lookup_locally_or_in_crate_store<V, F>(descr: &str,
                                          def_id: DefId,
                                          map: &RefCell<DefIdMap<V>>,
                                          load_external: F) -> V where
    V: Clone,
    F: FnOnce() -> V,
{
    match map.borrow().get(&def_id).cloned() {
        Some(v) => { return v; }
        None => { }
    }
    if def_id.is_local() {
        panic!("No def'n found for {:?} in tcx.{}", def_id, descr);
    }
    let v = load_external();
    map.borrow_mut().insert(def_id, v.clone());
    v
}
fn lookup_locally_or_in_crate_store < V , F > ( descr : & str , def_id : DefId , map : & RefCell < DefIdMap < V > > , load_external : F ) -> V where V : Clone , F : FnOnce ( ) -> V , { match map . borrow ( ) . get ( & def_id ) . cloned ( ) { Some ( v ) => { return v ; } None => { } } if def_id . is_local ( ) { panic ! ( " " def_id descr ) ; } let v = load_external ( ) ; map . borrow_mut ( ) . insert ( def_id , v . clone ( ) ) ; v }
Helper for looking things up in the various maps that are populated during
typeck::collect (e.g., `cx.impl_or_trait_items`, `cx.tcache`, etc).
Helper for looking things up in the various maps that are populated during typeck :: collect ( e . g . ` cx . impl_or_trait_items ` ` cx . tcache ` etc ) .
descr
&str
def_id
DefId
map
&RefCell<DefIdMap<V>>
load_external
F