- if def_id.krate != LOCAL_CRATE {
- return ccx.tcx.lookup_item_type(def_id);
- }
-
- match ccx.tcx.map.find(def_id.node) {
- Some(hir_map::NodeItem(item)) => {
- type_scheme_of_item(ccx, &*item)
- }
- Some(hir_map::NodeForeignItem(foreign_item)) => {
- let abi = ccx.tcx.map.get_foreign_abi(def_id.node);
- type_scheme_of_foreign_item(ccx, &*foreign_item, abi)
- }
- x => {
- ccx.tcx.sess.bug(&format!("unexpected sort of node \
- in get_item_type_scheme(): {:?}",
- x));
+ if let Some(node_id) = ccx.tcx.map.as_local_node_id(def_id) {
+ match ccx.tcx.map.find(node_id) {
+ Some(hir_map::NodeItem(item)) => {
+ type_scheme_of_item(ccx, &*item)
+ }
+ Some(hir_map::NodeForeignItem(foreign_item)) => {
+ let abi = ccx.tcx.map.get_foreign_abi(node_id);
+ type_scheme_of_foreign_item(ccx, &*foreign_item, abi)
+ }
+ x => {
+ ccx.tcx.sess.bug(&format!("unexpected sort of node \
+ in get_item_type_scheme(): {:?}",
+ x));
+ }