Skip to content

Commit 07957ff

Browse files
committed
Refactor Module's field extern_crate_did: Option<DefId> to extern_crate_id: Option<NodeId>
1 parent 8f32fde commit 07957ff

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
293293
self.external_exports.insert(def_id);
294294
let parent_link = ModuleParentLink(parent, name);
295295
let def = Def::Mod(def_id);
296-
let local_def_id = self.ast_map.local_def_id(item.id);
297-
let external_module =
298-
self.new_extern_crate_module(parent_link, def, is_public, local_def_id);
299-
self.define(parent, name, TypeNS, (external_module, sp));
296+
let module = self.new_extern_crate_module(parent_link, def, is_public, item.id);
297+
self.define(parent, name, TypeNS, (module, sp));
300298

301299
if is_public {
302300
let export = Export { name: name, def_id: def_id };
@@ -306,7 +304,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
306304
}
307305
}
308306

309-
self.build_reduced_graph_for_external_crate(external_module);
307+
self.build_reduced_graph_for_external_crate(module);
310308
}
311309
parent
312310
}

src/librustc_resolve/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,9 @@ pub struct ModuleS<'a> {
807807
def: Option<Def>,
808808
is_public: bool,
809809

810-
// If the module is an extern crate, `def` is root of the external crate and `extern_crate_did`
811-
// is the DefId of the local `extern crate` item (otherwise, `extern_crate_did` is None).
812-
extern_crate_did: Option<DefId>,
810+
// If the module is an extern crate, `def` is root of the external crate and `extern_crate_id`
811+
// is the NodeId of the local `extern crate` item (otherwise, `extern_crate_id` is None).
812+
extern_crate_id: Option<NodeId>,
813813

814814
resolutions: RefCell<HashMap<(Name, Namespace), NameResolution<'a>>>,
815815
unresolved_imports: RefCell<Vec<ImportDirective>>,
@@ -856,7 +856,7 @@ impl<'a> ModuleS<'a> {
856856
parent_link: parent_link,
857857
def: def,
858858
is_public: is_public,
859-
extern_crate_did: None,
859+
extern_crate_id: None,
860860
resolutions: RefCell::new(HashMap::new()),
861861
unresolved_imports: RefCell::new(Vec::new()),
862862
module_children: RefCell::new(NodeMap()),
@@ -1039,7 +1039,7 @@ impl<'a> NameBinding<'a> {
10391039
}
10401040

10411041
fn is_extern_crate(&self) -> bool {
1042-
self.module().and_then(|module| module.extern_crate_did).is_some()
1042+
self.module().and_then(|module| module.extern_crate_id).is_some()
10431043
}
10441044

10451045
fn is_import(&self) -> bool {
@@ -1237,10 +1237,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12371237
parent_link: ParentLink<'a>,
12381238
def: Def,
12391239
is_public: bool,
1240-
local_def: DefId)
1240+
local_node_id: NodeId)
12411241
-> Module<'a> {
12421242
let mut module = ModuleS::new(parent_link, Some(def), false, is_public);
1243-
module.extern_crate_did = Some(local_def);
1243+
module.extern_crate_id = Some(local_node_id);
12441244
self.arenas.modules.alloc(module)
12451245
}
12461246

0 commit comments

Comments
 (0)