]> git.lizzy.rs Git - rust.git/commitdiff
Refactor Module's field extern_crate_did: Option<DefId> to extern_crate_id: Option...
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Thu, 25 Feb 2016 05:23:50 +0000 (05:23 +0000)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Fri, 26 Feb 2016 00:37:27 +0000 (00:37 +0000)
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/lib.rs

index 385fae46cbae8672a5dc3101736df813a50f88b6..e59960ed4bd015a6e9bdd20c84db24d581c1b282 100644 (file)
@@ -293,10 +293,8 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
                     self.external_exports.insert(def_id);
                     let parent_link = ModuleParentLink(parent, name);
                     let def = Def::Mod(def_id);
-                    let local_def_id = self.ast_map.local_def_id(item.id);
-                    let external_module =
-                        self.new_extern_crate_module(parent_link, def, is_public, local_def_id);
-                    self.define(parent, name, TypeNS, (external_module, sp));
+                    let module = self.new_extern_crate_module(parent_link, def, is_public, item.id);
+                    self.define(parent, name, TypeNS, (module, sp));
 
                     if is_public {
                         let export = Export { name: name, def_id: def_id };
@@ -306,7 +304,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
                         }
                     }
 
-                    self.build_reduced_graph_for_external_crate(external_module);
+                    self.build_reduced_graph_for_external_crate(module);
                 }
                 parent
             }
index 2897714d57432c24c7d52b6d5811f6fe627c43d4..47e4da53f334259a77f8de7df0ca62c1e9c27224 100644 (file)
@@ -807,9 +807,9 @@ pub struct ModuleS<'a> {
     def: Option<Def>,
     is_public: bool,
 
-    // If the module is an extern crate, `def` is root of the external crate and `extern_crate_did`
-    // is the DefId of the local `extern crate` item (otherwise, `extern_crate_did` is None).
-    extern_crate_did: Option<DefId>,
+    // If the module is an extern crate, `def` is root of the external crate and `extern_crate_id`
+    // is the NodeId of the local `extern crate` item (otherwise, `extern_crate_id` is None).
+    extern_crate_id: Option<NodeId>,
 
     resolutions: RefCell<HashMap<(Name, Namespace), NameResolution<'a>>>,
     unresolved_imports: RefCell<Vec<ImportDirective>>,
@@ -856,7 +856,7 @@ fn new(parent_link: ParentLink<'a>, def: Option<Def>, external: bool, is_public:
             parent_link: parent_link,
             def: def,
             is_public: is_public,
-            extern_crate_did: None,
+            extern_crate_id: None,
             resolutions: RefCell::new(HashMap::new()),
             unresolved_imports: RefCell::new(Vec::new()),
             module_children: RefCell::new(NodeMap()),
@@ -1039,7 +1039,7 @@ fn is_public(&self) -> bool {
     }
 
     fn is_extern_crate(&self) -> bool {
-        self.module().and_then(|module| module.extern_crate_did).is_some()
+        self.module().and_then(|module| module.extern_crate_id).is_some()
     }
 
     fn is_import(&self) -> bool {
@@ -1237,10 +1237,10 @@ fn new_extern_crate_module(&self,
                                parent_link: ParentLink<'a>,
                                def: Def,
                                is_public: bool,
-                               local_def: DefId)
+                               local_node_id: NodeId)
                                -> Module<'a> {
         let mut module = ModuleS::new(parent_link, Some(def), false, is_public);
-        module.extern_crate_did = Some(local_def);
+        module.extern_crate_id = Some(local_node_id);
         self.arenas.modules.alloc(module)
     }