pub fn lookup_item(&self, names: &[String]) -> ast::NodeId {
        return match search_mod(self, &self.infcx.tcx.hir.krate().module, 0, names) {
            Some(id) => id,
            None => {
                panic!("no item found: `{}`", names.join("::"));
            }
        };

        fn search_mod(this: &Env,
                      m: &hir::Mod,
                      idx: usize,
                      names: &[String])
                      -> Option<ast::NodeId> {
            assert!(idx < names.len());
            for item in &m.item_ids {
                let item = this.infcx.tcx.hir.expect_item(item.id);
                if item.name.to_string() == names[idx] {
                    return search(this, item, idx + 1, names);
                }
            }
            return None;
        }

        fn search(this: &Env, it: &hir::Item, idx: usize, names: &[String]) -> Option<ast::NodeId> {
            if idx == names.len() {
                return Some(it.id);
            }

            return match it.node {
                hir::ItemUse(..) |
                hir::ItemExternCrate(..) |
                hir::ItemConst(..) |
                hir::ItemStatic(..) |
                hir::ItemFn(..) |
                hir::ItemForeignMod(..) |
                hir::ItemGlobalAsm(..) |
                hir::ItemTy(..) => None,

                hir::ItemEnum(..) |
                hir::ItemStruct(..) |
                hir::ItemUnion(..) |
                hir::ItemTrait(..) |
                hir::ItemImpl(..) |
                hir::ItemDefaultImpl(..) => None,

                hir::ItemMod(ref m) => search_mod(this, m, idx, names),
            };
        }
    }
// this seems like it could be useful, even if we don't use it now
this seems like it could be useful, even if we don't use it now
this seems like it could be useful even if we don ' t use it now
pub fn lookup_item(&self, names: &[String]) -> ast::NodeId {
        return match search_mod(self, &self.infcx.tcx.hir.krate().module, 0, names) {
            Some(id) => id,
            None => {
                panic!("no item found: `{}`", names.join("::"));
            }
        };
        fn search_mod(this: &Env,
                      m: &hir::Mod,
                      idx: usize,
                      names: &[String])
                      -> Option<ast::NodeId> {
            assert!(idx < names.len());
            for item in &m.item_ids {
                let item = this.infcx.tcx.hir.expect_item(item.id);
                if item.name.to_string() == names[idx] {
                    return search(this, item, idx + 1, names);
                }
            }
            return None;
        }
        fn search(this: &Env, it: &hir::Item, idx: usize, names: &[String]) -> Option<ast::NodeId> {
            if idx == names.len() {
                return Some(it.id);
            }
            return match it.node {
                hir::ItemUse(..) |
                hir::ItemExternCrate(..) |
                hir::ItemConst(..) |
                hir::ItemStatic(..) |
                hir::ItemFn(..) |
                hir::ItemForeignMod(..) |
                hir::ItemGlobalAsm(..) |
                hir::ItemTy(..) => None,
                hir::ItemEnum(..) |
                hir::ItemStruct(..) |
                hir::ItemUnion(..) |
                hir::ItemTrait(..) |
                hir::ItemImpl(..) |
                hir::ItemDefaultImpl(..) => None,
                hir::ItemMod(ref m) => search_mod(this, m, idx, names),
            };
        }
    }
pub fn lookup_item ( & self , names : & [ String ] ) -> ast :: NodeId { return match search_mod ( self , & self . infcx . tcx . hir . krate ( ) . module , 0 , names ) { Some ( id ) => id , None => { panic ! ( " " names join ( " " ) ) ; } } ; fn search_mod ( this : & Env , m : & hir :: Mod , idx : usize , names : & [ String ] ) -> Option < ast :: NodeId > { assert ! ( idx names len ( ) ) ; for item in & m . item_ids { let item = this . infcx . tcx . hir . expect_item ( item . id ) ; if item . name . to_string ( ) == names [ idx ] { return search ( this , item , idx + 1 , names ) ; } } return None ; } fn search ( this : & Env , it : & hir :: Item , idx : usize , names : & [ String ] ) -> Option < ast :: NodeId > { if idx == names . len ( ) { return Some ( it . id ) ; } return match it . node { hir :: ItemUse ( .. ) | hir :: ItemExternCrate ( .. ) | hir :: ItemConst ( .. ) | hir :: ItemStatic ( .. ) | hir :: ItemFn ( .. ) | hir :: ItemForeignMod ( .. ) | hir :: ItemGlobalAsm ( .. ) | hir :: ItemTy ( .. ) => None , hir :: ItemEnum ( .. ) | hir :: ItemStruct ( .. ) | hir :: ItemUnion ( .. ) | hir :: ItemTrait ( .. ) | hir :: ItemImpl ( .. ) | hir :: ItemDefaultImpl ( .. ) => None , hir :: ItemMod ( ref m ) => search_mod ( this , m , idx , names ) , } ; } }
this seems like it could be useful, even if we don't use it now
this seems like it could be useful even if we don ' t use it now
&self
names
&[String]
&self
names
&[String]