Skip to content

Commit 63b4dd9

Browse files
committedFeb 24, 2019
hir: remove NodeId from MacroDef
1 parent c886d47 commit 63b4dd9

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed
 

‎src/librustc/hir/lowering.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3532,7 +3532,6 @@ impl<'a> LoweringContext<'a> {
35323532
name: ident.name,
35333533
vis,
35343534
attrs,
3535-
id: i.id,
35363535
hir_id,
35373536
span: i.span,
35383537
body,

‎src/librustc/hir/map/collector.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
507507
}
508508

509509
fn visit_macro_def(&mut self, macro_def: &'hir MacroDef) {
510-
let def_index = self.definitions.opt_def_index(macro_def.id).unwrap();
510+
let node_id = self.hir_to_node_id[&macro_def.hir_id];
511+
let def_index = self.definitions.opt_def_index(node_id).unwrap();
511512

512513
self.with_dep_node_owner(def_index, macro_def, |this| {
513514
this.insert(macro_def.span, macro_def.hir_id, Node::MacroDef(macro_def));

‎src/librustc/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl<'hir> Map<'hir> {
390390
Some(Def::Local(local.id))
391391
}
392392
Node::MacroDef(macro_def) => {
393-
Some(Def::Macro(self.local_def_id(macro_def.id),
393+
Some(Def::Macro(self.local_def_id_from_hir_id(macro_def.hir_id),
394394
MacroKind::Bang))
395395
}
396396
Node::GenericParam(param) => {

‎src/librustc/hir/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,6 @@ pub struct MacroDef {
809809
pub name: Name,
810810
pub vis: Visibility,
811811
pub attrs: HirVec<Attribute>,
812-
pub id: NodeId,
813812
pub hir_id: HirId,
814813
pub span: Span,
815814
pub body: TokenStream,

‎src/librustc/ich/impls_hir.rs

-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ impl_stable_hash_for!(struct hir::MacroDef {
406406
name,
407407
vis,
408408
attrs,
409-
id,
410409
hir_id,
411410
span,
412411
legacy,

‎src/librustc_metadata/encoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
12791279
/// Serialize the text of exported macros
12801280
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> {
12811281
use syntax::print::pprust;
1282-
let def_id = self.tcx.hir().local_def_id(macro_def.id);
1282+
let def_id = self.tcx.hir().local_def_id_from_hir_id(macro_def.hir_id);
12831283
Entry {
12841284
kind: EntryKind::MacroDef(self.lazy(&MacroDef {
12851285
body: pprust::tts_to_string(&macro_def.body.trees().collect::<Vec<_>>()),
@@ -1680,7 +1680,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
16801680
self.index.encode_info_for_ty(ty);
16811681
}
16821682
fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef) {
1683-
let def_id = self.index.tcx.hir().local_def_id(macro_def.id);
1683+
let def_id = self.index.tcx.hir().local_def_id_from_hir_id(macro_def.hir_id);
16841684
self.index.record(def_id, IsolatedEncoder::encode_info_for_macro_def, macro_def);
16851685
}
16861686
}

‎src/librustc_metadata/index_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ macro_rules! read_hir {
185185
($t:ty) => {
186186
impl<'tcx> DepGraphRead for &'tcx $t {
187187
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
188-
tcx.hir().read(self.id);
188+
tcx.hir().read_by_hir_id(self.hir_id);
189189
}
190190
}
191191
}

‎src/librustc_privacy/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -695,18 +695,20 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
695695
}
696696

697697
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
698+
let node_id = self.tcx.hir().hir_to_node_id(md.hir_id);
699+
698700
if md.legacy {
699-
self.update(md.id, Some(AccessLevel::Public));
701+
self.update(node_id, Some(AccessLevel::Public));
700702
return
701703
}
702704

703705
let module_did = ty::DefIdTree::parent(
704706
self.tcx,
705-
self.tcx.hir().local_def_id(md.id)
707+
self.tcx.hir().local_def_id_from_hir_id(md.hir_id)
706708
).unwrap();
707709
let mut module_id = self.tcx.hir().as_local_node_id(module_did).unwrap();
708710
let level = if md.vis.node.is_pub() { self.get(module_id) } else { None };
709-
let level = self.update(md.id, level);
711+
let level = self.update(node_id, level);
710712
if level.is_none() {
711713
return
712714
}

0 commit comments

Comments
 (0)
Please sign in to comment.