hir: remove NodeId from MacroDef

This commit is contained in:
ljedrz 2019-02-18 15:55:00 +01:00
parent c886d47b82
commit 63b4dd91be
8 changed files with 11 additions and 11 deletions

View File

@ -3532,7 +3532,6 @@ impl<'a> LoweringContext<'a> {
name: ident.name, name: ident.name,
vis, vis,
attrs, attrs,
id: i.id,
hir_id, hir_id,
span: i.span, span: i.span,
body, body,

View File

@ -507,7 +507,8 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
} }
fn visit_macro_def(&mut self, macro_def: &'hir MacroDef) { fn visit_macro_def(&mut self, macro_def: &'hir MacroDef) {
let def_index = self.definitions.opt_def_index(macro_def.id).unwrap(); let node_id = self.hir_to_node_id[&macro_def.hir_id];
let def_index = self.definitions.opt_def_index(node_id).unwrap();
self.with_dep_node_owner(def_index, macro_def, |this| { self.with_dep_node_owner(def_index, macro_def, |this| {
this.insert(macro_def.span, macro_def.hir_id, Node::MacroDef(macro_def)); this.insert(macro_def.span, macro_def.hir_id, Node::MacroDef(macro_def));

View File

@ -390,7 +390,7 @@ impl<'hir> Map<'hir> {
Some(Def::Local(local.id)) Some(Def::Local(local.id))
} }
Node::MacroDef(macro_def) => { Node::MacroDef(macro_def) => {
Some(Def::Macro(self.local_def_id(macro_def.id), Some(Def::Macro(self.local_def_id_from_hir_id(macro_def.hir_id),
MacroKind::Bang)) MacroKind::Bang))
} }
Node::GenericParam(param) => { Node::GenericParam(param) => {

View File

@ -809,7 +809,6 @@ pub struct MacroDef {
pub name: Name, pub name: Name,
pub vis: Visibility, pub vis: Visibility,
pub attrs: HirVec<Attribute>, pub attrs: HirVec<Attribute>,
pub id: NodeId,
pub hir_id: HirId, pub hir_id: HirId,
pub span: Span, pub span: Span,
pub body: TokenStream, pub body: TokenStream,

View File

@ -406,7 +406,6 @@ impl_stable_hash_for!(struct hir::MacroDef {
name, name,
vis, vis,
attrs, attrs,
id,
hir_id, hir_id,
span, span,
legacy, legacy,

View File

@ -1279,7 +1279,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
/// Serialize the text of exported macros /// Serialize the text of exported macros
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> { fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> {
use syntax::print::pprust; use syntax::print::pprust;
let def_id = self.tcx.hir().local_def_id(macro_def.id); let def_id = self.tcx.hir().local_def_id_from_hir_id(macro_def.hir_id);
Entry { Entry {
kind: EntryKind::MacroDef(self.lazy(&MacroDef { kind: EntryKind::MacroDef(self.lazy(&MacroDef {
body: pprust::tts_to_string(&macro_def.body.trees().collect::<Vec<_>>()), 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> {
self.index.encode_info_for_ty(ty); self.index.encode_info_for_ty(ty);
} }
fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef) { fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef) {
let def_id = self.index.tcx.hir().local_def_id(macro_def.id); let def_id = self.index.tcx.hir().local_def_id_from_hir_id(macro_def.hir_id);
self.index.record(def_id, IsolatedEncoder::encode_info_for_macro_def, macro_def); self.index.record(def_id, IsolatedEncoder::encode_info_for_macro_def, macro_def);
} }
} }

View File

@ -185,7 +185,7 @@ macro_rules! read_hir {
($t:ty) => { ($t:ty) => {
impl<'tcx> DepGraphRead for &'tcx $t { impl<'tcx> DepGraphRead for &'tcx $t {
fn read(&self, tcx: TyCtxt<'_, '_, '_>) { fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
tcx.hir().read(self.id); tcx.hir().read_by_hir_id(self.hir_id);
} }
} }
} }

View File

@ -695,18 +695,20 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
} }
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) { fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
let node_id = self.tcx.hir().hir_to_node_id(md.hir_id);
if md.legacy { if md.legacy {
self.update(md.id, Some(AccessLevel::Public)); self.update(node_id, Some(AccessLevel::Public));
return return
} }
let module_did = ty::DefIdTree::parent( let module_did = ty::DefIdTree::parent(
self.tcx, self.tcx,
self.tcx.hir().local_def_id(md.id) self.tcx.hir().local_def_id_from_hir_id(md.hir_id)
).unwrap(); ).unwrap();
let mut module_id = self.tcx.hir().as_local_node_id(module_did).unwrap(); let mut module_id = self.tcx.hir().as_local_node_id(module_did).unwrap();
let level = if md.vis.node.is_pub() { self.get(module_id) } else { None }; let level = if md.vis.node.is_pub() { self.get(module_id) } else { None };
let level = self.update(md.id, level); let level = self.update(node_id, level);
if level.is_none() { if level.is_none() {
return return
} }