Skip to content

Commit 77fa041

Browse files
committed
hir: remove NodeId from Item
1 parent 3c25193 commit 77fa041

File tree

42 files changed

+208
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+208
-212
lines changed

src/librustc/hir/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
9494
/// Checks any attribute.
9595
fn check_attributes(&self, item: &hir::Item, target: Target) {
9696
if target == Target::Fn || target == Target::Const {
97-
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(item.id));
97+
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id_from_hir_id(item.hir_id));
9898
} else if let Some(a) = item.attrs.iter().find(|a| a.check_name("target_feature")) {
9999
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function")
100100
.span_label(item.span, "not a function")

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,6 @@ impl<'a> LoweringContext<'a> {
14141414

14151415
trace!("exist ty def index: {:#?}", exist_ty_def_index);
14161416
let exist_ty_item = hir::Item {
1417-
id: exist_ty_id.node_id,
14181417
hir_id: exist_ty_id.hir_id,
14191418
ident: keywords::Invalid.ident(),
14201419
attrs: Default::default(),
@@ -3128,7 +3127,6 @@ impl<'a> LoweringContext<'a> {
31283127
this.insert_item(
31293128
new_id.node_id,
31303129
hir::Item {
3131-
id: new_id.node_id,
31323130
hir_id: new_id.hir_id,
31333131
ident,
31343132
attrs: attrs.clone(),
@@ -3234,7 +3232,6 @@ impl<'a> LoweringContext<'a> {
32343232
this.insert_item(
32353233
new_id,
32363234
hir::Item {
3237-
id: new_id,
32383235
hir_id: new_hir_id,
32393236
ident,
32403237
attrs: attrs.clone(),
@@ -3534,10 +3531,9 @@ impl<'a> LoweringContext<'a> {
35343531

35353532
let node = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.node);
35363533

3537-
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(i.id);
3534+
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(i.id);
35383535

35393536
Some(hir::Item {
3540-
id: node_id,
35413537
hir_id,
35423538
ident,
35433539
attrs,

src/librustc/hir/map/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
356356
fn visit_item(&mut self, i: &'hir Item) {
357357
debug!("visit_item: {:?}", i);
358358
debug_assert_eq!(i.hir_id.owner,
359-
self.definitions.opt_def_index(i.id).unwrap());
359+
self.definitions.opt_def_index(self.hir_to_node_id[&i.hir_id]).unwrap());
360360
self.with_dep_node_owner(i.hir_id.owner, i, |this| {
361361
this.insert(i.span, i.hir_id, Node::Item(i));
362362
this.with_parent(i.hir_id, |this| {

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<'hir> Map<'hir> {
319319

320320
match node {
321321
Node::Item(item) => {
322-
let def_id = || self.local_def_id(item.id);
322+
let def_id = || self.local_def_id_from_hir_id(item.hir_id);
323323

324324
match item.node {
325325
ItemKind::Static(_, m, _) => Some(Def::Static(def_id(), m == MutMutable)),

src/librustc/hir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2221,7 +2221,6 @@ pub struct ItemId {
22212221
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
22222222
pub struct Item {
22232223
pub ident: Ident,
2224-
pub id: NodeId,
22252224
pub hir_id: HirId,
22262225
pub attrs: HirVec<Attribute>,
22272226
pub node: ItemKind,

src/librustc/ich/impls_hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
856856
let hir::Item {
857857
ident,
858858
ref attrs,
859-
id: _,
860859
hir_id: _,
861860
ref node,
862861
ref vis,

src/librustc/middle/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
152152
Node::Item(item) => {
153153
match item.node {
154154
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
155-
let def_id = self.tcx.hir().local_def_id(item.id);
155+
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
156156
let def = self.tcx.adt_def(def_id);
157157
self.repr_has_repr_c = def.repr.c();
158158

src/librustc/middle/entry.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ use crate::hir::map as hir_map;
22
use crate::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
33
use crate::session::{config, Session};
44
use crate::session::config::EntryFnType;
5-
use syntax::ast::NodeId;
65
use syntax::attr;
76
use syntax::entry::EntryPointType;
87
use syntax_pos::Span;
9-
use crate::hir::{Item, ItemKind, ImplItem, TraitItem};
8+
use crate::hir::{HirId, Item, ItemKind, ImplItem, TraitItem};
109
use crate::hir::itemlikevisit::ItemLikeVisitor;
1110
use crate::ty::TyCtxt;
1211
use crate::ty::query::Providers;
@@ -17,22 +16,22 @@ struct EntryContext<'a, 'tcx: 'a> {
1716
map: &'a hir_map::Map<'tcx>,
1817

1918
// The top-level function called 'main'
20-
main_fn: Option<(NodeId, Span)>,
19+
main_fn: Option<(HirId, Span)>,
2120

2221
// The function that has attribute named 'main'
23-
attr_main_fn: Option<(NodeId, Span)>,
22+
attr_main_fn: Option<(HirId, Span)>,
2423

2524
// The function that has the attribute 'start' on it
26-
start_fn: Option<(NodeId, Span)>,
25+
start_fn: Option<(HirId, Span)>,
2726

2827
// The functions that one might think are 'main' but aren't, e.g.
2928
// main functions not defined at the top level. For diagnostics.
30-
non_main_fns: Vec<(NodeId, Span)> ,
29+
non_main_fns: Vec<(HirId, Span)> ,
3130
}
3231

3332
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
3433
fn visit_item(&mut self, item: &'tcx Item) {
35-
let def_id = self.map.local_def_id(item.id);
34+
let def_id = self.map.local_def_id_from_hir_id(item.hir_id);
3635
let def_key = self.map.def_key(def_id);
3736
let at_root = def_key.parent == Some(CRATE_DEF_INDEX);
3837
find_item(item, self, at_root);
@@ -106,18 +105,18 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
106105
match entry_point_type(item, at_root) {
107106
EntryPointType::MainNamed => {
108107
if ctxt.main_fn.is_none() {
109-
ctxt.main_fn = Some((item.id, item.span));
108+
ctxt.main_fn = Some((item.hir_id, item.span));
110109
} else {
111110
span_err!(ctxt.session, item.span, E0136,
112111
"multiple 'main' functions");
113112
}
114113
},
115114
EntryPointType::OtherMain => {
116-
ctxt.non_main_fns.push((item.id, item.span));
115+
ctxt.non_main_fns.push((item.hir_id, item.span));
117116
},
118117
EntryPointType::MainAttr => {
119118
if ctxt.attr_main_fn.is_none() {
120-
ctxt.attr_main_fn = Some((item.id, item.span));
119+
ctxt.attr_main_fn = Some((item.hir_id, item.span));
121120
} else {
122121
struct_span_err!(ctxt.session, item.span, E0137,
123122
"multiple functions with a #[main] attribute")
@@ -128,7 +127,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
128127
},
129128
EntryPointType::Start => {
130129
if ctxt.start_fn.is_none() {
131-
ctxt.start_fn = Some((item.id, item.span));
130+
ctxt.start_fn = Some((item.hir_id, item.span));
132131
} else {
133132
struct_span_err!(ctxt.session, item.span, E0138, "multiple 'start' functions")
134133
.span_label(ctxt.start_fn.unwrap().1, "previous `start` function here")
@@ -144,12 +143,12 @@ fn configure_main(
144143
tcx: TyCtxt<'_, '_, '_>,
145144
visitor: &EntryContext<'_, '_>,
146145
) -> Option<(DefId, EntryFnType)> {
147-
if let Some((node_id, _)) = visitor.start_fn {
148-
Some((tcx.hir().local_def_id(node_id), EntryFnType::Start))
149-
} else if let Some((node_id, _)) = visitor.attr_main_fn {
150-
Some((tcx.hir().local_def_id(node_id), EntryFnType::Main))
151-
} else if let Some((node_id, _)) = visitor.main_fn {
152-
Some((tcx.hir().local_def_id(node_id), EntryFnType::Main))
146+
if let Some((hir_id, _)) = visitor.start_fn {
147+
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Start))
148+
} else if let Some((hir_id, _)) = visitor.attr_main_fn {
149+
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Main))
150+
} else if let Some((hir_id, _)) = visitor.main_fn {
151+
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Main))
153152
} else {
154153
// No main function
155154
let mut err = struct_err!(tcx.sess, E0601,

src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> {
9898
match self.item_refs.get(&*value.as_str()).cloned() {
9999
// Known lang item with attribute on correct target.
100100
Some((item_index, expected_target)) if actual_target == expected_target => {
101-
let def_id = self.tcx.hir().local_def_id(item.id);
101+
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
102102
self.collect_item(item_index, def_id);
103103
},
104104
// Known lang item with attribute on incorrect target.

src/librustc/middle/reachable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>,
3636
match item.node {
3737
hir::ItemKind::Impl(..) |
3838
hir::ItemKind::Fn(..) => {
39-
let generics = tcx.generics_of(tcx.hir().local_def_id(item.id));
39+
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(item.hir_id));
4040
generics.requires_monomorphization(tcx)
4141
}
4242
_ => false,
@@ -344,7 +344,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a,
344344
// Anything which has custom linkage gets thrown on the worklist no
345345
// matter where it is in the crate, along with "special std symbols"
346346
// which are currently akin to allocator symbols.
347-
let def_id = self.tcx.hir().local_def_id(item.id);
347+
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
348348
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
349349
if codegen_attrs.contains_extern_indicator() ||
350350
codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) {

0 commit comments

Comments
 (0)