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,
vis,
attrs,
id: i.id,
hir_id,
span: i.span,
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) {
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| {
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))
}
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))
}
Node::GenericParam(param) => {

View File

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

View File

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

View File

@ -1279,7 +1279,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
/// Serialize the text of exported macros
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> {
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 {
kind: EntryKind::MacroDef(self.lazy(&MacroDef {
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);
}
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);
}
}

View File

@ -185,7 +185,7 @@ macro_rules! read_hir {
($t:ty) => {
impl<'tcx> DepGraphRead for &'tcx $t {
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) {
let node_id = self.tcx.hir().hir_to_node_id(md.hir_id);
if md.legacy {
self.update(md.id, Some(AccessLevel::Public));
self.update(node_id, Some(AccessLevel::Public));
return
}
let module_did = ty::DefIdTree::parent(
self.tcx,
self.tcx.hir().local_def_id(md.id)
self.tcx.hir().local_def_id_from_hir_id(md.hir_id)
).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 = self.update(md.id, level);
let level = self.update(node_id, level);
if level.is_none() {
return
}