Skip to content

Commit e72584c

Browse files
committed
hir: remove NodeId from TraitItem
1 parent 43294c6 commit e72584c

File tree

22 files changed

+149
-148
lines changed

22 files changed

+149
-148
lines changed

src/librustc/hir/lowering.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3351,7 +3351,6 @@ impl<'a> LoweringContext<'a> {
33513351
};
33523352

33533353
hir::TraitItem {
3354-
id: node_id,
33553354
hir_id,
33563355
ident: i.ident,
33573356
attrs: self.lower_attrs(&i.attrs),

src/librustc/hir/map/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
386386

387387
fn visit_trait_item(&mut self, ti: &'hir TraitItem) {
388388
debug_assert_eq!(ti.hir_id.owner,
389-
self.definitions.opt_def_index(ti.id).unwrap());
389+
self.definitions.opt_def_index(self.hir_to_node_id[&ti.hir_id]).unwrap());
390390
self.with_dep_node_owner(ti.hir_id.owner, ti, |this| {
391391
this.insert(ti.span, ti.hir_id, Node::TraitItem(ti));
392392

src/librustc/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl<'hir> Map<'hir> {
349349
}
350350
}
351351
Node::TraitItem(item) => {
352-
let def_id = self.local_def_id(item.id);
352+
let def_id = self.local_def_id_from_hir_id(item.hir_id);
353353
match item.node {
354354
TraitItemKind::Const(..) => Some(Def::AssociatedConst(def_id)),
355355
TraitItemKind::Method(..) => Some(Def::Method(def_id)),

src/librustc/hir/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,6 @@ pub struct TraitItemId {
16681668
/// signature) or provided (meaning it has a default implementation).
16691669
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
16701670
pub struct TraitItem {
1671-
pub id: NodeId,
16721671
pub ident: Ident,
16731672
pub hir_id: HirId,
16741673
pub attrs: HirVec<Attribute>,

src/librustc/hir/print.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub enum AnnNode<'a> {
2525
Name(&'a ast::Name),
2626
Block(&'a hir::Block),
2727
Item(&'a hir::Item),
28-
SubItem(ast::NodeId),
28+
SubItem(hir::HirId),
2929
Expr(&'a hir::Expr),
3030
Pat(&'a hir::Pat),
3131
}
@@ -927,7 +927,7 @@ impl<'a> State<'a> {
927927
}
928928

929929
pub fn print_trait_item(&mut self, ti: &hir::TraitItem) -> io::Result<()> {
930-
self.ann.pre(self, AnnNode::SubItem(ti.id))?;
930+
self.ann.pre(self, AnnNode::SubItem(ti.hir_id))?;
931931
self.hardbreak_if_not_bol()?;
932932
self.maybe_print_comment(ti.span.lo())?;
933933
self.print_outer_attributes(&ti.attrs)?;
@@ -959,11 +959,11 @@ impl<'a> State<'a> {
959959
default.as_ref().map(|ty| &**ty))?;
960960
}
961961
}
962-
self.ann.post(self, AnnNode::SubItem(ti.id))
962+
self.ann.post(self, AnnNode::SubItem(ti.hir_id))
963963
}
964964

965965
pub fn print_impl_item(&mut self, ii: &hir::ImplItem) -> io::Result<()> {
966-
self.ann.pre(self, AnnNode::SubItem(ii.id))?;
966+
self.ann.pre(self, AnnNode::SubItem(ii.hir_id))?;
967967
self.hardbreak_if_not_bol()?;
968968
self.maybe_print_comment(ii.span.lo())?;
969969
self.print_outer_attributes(&ii.attrs)?;
@@ -989,7 +989,7 @@ impl<'a> State<'a> {
989989
self.print_associated_type(ii.ident, Some(bounds), None)?;
990990
}
991991
}
992-
self.ann.post(self, AnnNode::SubItem(ii.id))
992+
self.ann.post(self, AnnNode::SubItem(ii.hir_id))
993993
}
994994

995995
pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> {

src/librustc/ich/impls_hir.rs

-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
669669
hcx: &mut StableHashingContext<'a>,
670670
hasher: &mut StableHasher<W>) {
671671
let hir::TraitItem {
672-
id: _,
673672
hir_id: _,
674673
ident,
675674
ref attrs,

src/librustc/lint/context.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -793,11 +793,11 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
793793
run_lints!(self, exit_lint_attrs, attrs);
794794
}
795795

796-
fn with_param_env<F>(&mut self, id: ast::NodeId, f: F)
796+
fn with_param_env<F>(&mut self, id: hir::HirId, f: F)
797797
where F: FnOnce(&mut Self),
798798
{
799799
let old_param_env = self.param_env;
800-
self.param_env = self.tcx.param_env(self.tcx.hir().local_def_id(id));
800+
self.param_env = self.tcx.param_env(self.tcx.hir().local_def_id_from_hir_id(id));
801801
f(self);
802802
self.param_env = old_param_env;
803803
}
@@ -841,7 +841,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
841841
let generics = self.generics.take();
842842
self.generics = it.node.generics();
843843
self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
844-
cx.with_param_env(it.id, |cx| {
844+
cx.with_param_env(it.hir_id, |cx| {
845845
run_lints!(cx, check_item, it);
846846
hir_visit::walk_item(cx, it);
847847
run_lints!(cx, check_item_post, it);
@@ -852,7 +852,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
852852

853853
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) {
854854
self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
855-
cx.with_param_env(it.id, |cx| {
855+
cx.with_param_env(it.hir_id, |cx| {
856856
run_lints!(cx, check_foreign_item, it);
857857
hir_visit::walk_foreign_item(cx, it);
858858
run_lints!(cx, check_foreign_item_post, it);
@@ -983,7 +983,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
983983
let generics = self.generics.take();
984984
self.generics = Some(&trait_item.generics);
985985
self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |cx| {
986-
cx.with_param_env(trait_item.id, |cx| {
986+
cx.with_param_env(trait_item.hir_id, |cx| {
987987
run_lints!(cx, check_trait_item, trait_item);
988988
hir_visit::walk_trait_item(cx, trait_item);
989989
run_lints!(cx, check_trait_item_post, trait_item);
@@ -996,7 +996,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
996996
let generics = self.generics.take();
997997
self.generics = Some(&impl_item.generics);
998998
self.with_lint_attrs(impl_item.hir_id, &impl_item.attrs, |cx| {
999-
cx.with_param_env(impl_item.id, |cx| {
999+
cx.with_param_env(impl_item.hir_id, |cx| {
10001000
run_lints!(cx, check_impl_item, impl_item);
10011001
hir_visit::walk_impl_item(cx, impl_item);
10021002
run_lints!(cx, check_impl_item_post, impl_item);

src/librustc/middle/resolve_lifetime.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
781781
Method(ref sig, _) => {
782782
let tcx = self.tcx;
783783
self.visit_early_late(
784-
Some(tcx.hir().get_parent(trait_item.id)),
784+
Some(tcx.hir().get_parent_item(trait_item.hir_id)),
785785
&sig.decl,
786786
&trait_item.generics,
787787
|this| intravisit::walk_trait_item(this, trait_item),
@@ -833,7 +833,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
833833
Method(ref sig, _) => {
834834
let tcx = self.tcx;
835835
self.visit_early_late(
836-
Some(tcx.hir().get_parent(impl_item.id)),
836+
Some(tcx.hir().get_parent_item(impl_item.hir_id)),
837837
&sig.decl,
838838
&impl_item.generics,
839839
|this| intravisit::walk_impl_item(this, impl_item),
@@ -1685,7 +1685,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
16851685
/// ordering is not important there.
16861686
fn visit_early_late<F>(
16871687
&mut self,
1688-
parent_id: Option<ast::NodeId>,
1688+
parent_id: Option<hir::HirId>,
16891689
decl: &'tcx hir::FnDecl,
16901690
generics: &'tcx hir::Generics,
16911691
walk: F,
@@ -1697,7 +1697,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
16971697
// Find the start of nested early scopes, e.g., in methods.
16981698
let mut index = 0;
16991699
if let Some(parent_id) = parent_id {
1700-
let parent = self.tcx.hir().expect_item(parent_id);
1700+
let parent = self.tcx.hir().expect_item_by_hir_id(parent_id);
17011701
if sub_items_have_self_param(&parent.node) {
17021702
index += 1; // Self comes before lifetimes
17031703
}

src/librustc_codegen_utils/symbol_names_test.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
use rustc::hir;
88
use rustc::ty::TyCtxt;
9-
use syntax::ast;
109

1110
use rustc_mir::monomorphize::Instance;
1211

@@ -33,9 +32,9 @@ struct SymbolNamesTest<'a, 'tcx:'a> {
3332

3433
impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
3534
fn process_attrs(&mut self,
36-
node_id: ast::NodeId) {
35+
hir_id: hir::HirId) {
3736
let tcx = self.tcx;
38-
let def_id = tcx.hir().local_def_id(node_id);
37+
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
3938
for attr in tcx.get_attrs(def_id).iter() {
4039
if attr.check_name(SYMBOL_NAME) {
4140
// for now, can only use on monomorphic names
@@ -56,14 +55,14 @@ impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
5655

5756
impl<'a, 'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for SymbolNamesTest<'a, 'tcx> {
5857
fn visit_item(&mut self, item: &'tcx hir::Item) {
59-
self.process_attrs(item.id);
58+
self.process_attrs(item.hir_id);
6059
}
6160

6261
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
63-
self.process_attrs(trait_item.id);
62+
self.process_attrs(trait_item.hir_id);
6463
}
6564

6665
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
67-
self.process_attrs(impl_item.id);
66+
self.process_attrs(impl_item.hir_id);
6867
}
6968
}

src/librustc_incremental/assert_dep_graph.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
6969
let mut visitor = IfThisChanged { tcx,
7070
if_this_changed: vec![],
7171
then_this_would_need: vec![] };
72-
visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir().krate().attrs);
72+
visitor.process_attrs(hir::CRATE_HIR_ID, &tcx.hir().krate().attrs);
7373
tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
7474
(visitor.if_this_changed, visitor.then_this_would_need)
7575
};
@@ -87,7 +87,7 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
8787
}
8888

8989
type Sources = Vec<(Span, DefId, DepNode)>;
90-
type Targets = Vec<(Span, ast::Name, ast::NodeId, DepNode)>;
90+
type Targets = Vec<(Span, ast::Name, hir::HirId, DepNode)>;
9191

9292
struct IfThisChanged<'a, 'tcx:'a> {
9393
tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -110,8 +110,8 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
110110
value
111111
}
112112

113-
fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) {
114-
let def_id = self.tcx.hir().local_def_id(node_id);
113+
fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
114+
let def_id = self.tcx.hir().local_def_id_from_hir_id(hir_id);
115115
let def_path_hash = self.tcx.def_path_hash(def_id);
116116
for attr in attrs {
117117
if attr.check_name(ATTR_IF_THIS_CHANGED) {
@@ -151,7 +151,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
151151
};
152152
self.then_this_would_need.push((attr.span,
153153
dep_node_interned.unwrap(),
154-
node_id,
154+
hir_id,
155155
dep_node));
156156
}
157157
}
@@ -164,22 +164,22 @@ impl<'a, 'tcx> Visitor<'tcx> for IfThisChanged<'a, 'tcx> {
164164
}
165165

166166
fn visit_item(&mut self, item: &'tcx hir::Item) {
167-
self.process_attrs(item.id, &item.attrs);
167+
self.process_attrs(item.hir_id, &item.attrs);
168168
intravisit::walk_item(self, item);
169169
}
170170

171171
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
172-
self.process_attrs(trait_item.id, &trait_item.attrs);
172+
self.process_attrs(trait_item.hir_id, &trait_item.attrs);
173173
intravisit::walk_trait_item(self, trait_item);
174174
}
175175

176176
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
177-
self.process_attrs(impl_item.id, &impl_item.attrs);
177+
self.process_attrs(impl_item.hir_id, &impl_item.attrs);
178178
intravisit::walk_impl_item(self, impl_item);
179179
}
180180

181181
fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
182-
self.process_attrs(s.id, &s.attrs);
182+
self.process_attrs(s.hir_id, &s.attrs);
183183
intravisit::walk_struct_field(self, s);
184184
}
185185
}

src/librustc_incremental/persist/dirty_clean.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub struct DirtyCleanVisitor<'a, 'tcx:'a> {
241241
impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
242242

243243
/// Possibly "deserialize" the attribute into a clean/dirty assertion
244-
fn assertion_maybe(&mut self, item_id: ast::NodeId, attr: &Attribute)
244+
fn assertion_maybe(&mut self, item_id: hir::HirId, attr: &Attribute)
245245
-> Option<Assertion>
246246
{
247247
let is_clean = if attr.check_name(ATTR_DIRTY) {
@@ -269,7 +269,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
269269
}
270270

271271
/// Gets the "auto" assertion on pre-validated attr, along with the `except` labels.
272-
fn assertion_auto(&mut self, item_id: ast::NodeId, attr: &Attribute, is_clean: bool)
272+
fn assertion_auto(&mut self, item_id: hir::HirId, attr: &Attribute, is_clean: bool)
273273
-> Assertion
274274
{
275275
let (name, mut auto) = self.auto_labels(item_id, attr);
@@ -321,8 +321,8 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
321321

322322
/// Return all DepNode labels that should be asserted for this item.
323323
/// index=0 is the "name" used for error messages
324-
fn auto_labels(&mut self, item_id: ast::NodeId, attr: &Attribute) -> (&'static str, Labels) {
325-
let node = self.tcx.hir().get(item_id);
324+
fn auto_labels(&mut self, item_id: hir::HirId, attr: &Attribute) -> (&'static str, Labels) {
325+
let node = self.tcx.hir().get_by_hir_id(item_id);
326326
let (name, labels) = match node {
327327
HirNode::Item(item) => {
328328
match item.node {
@@ -499,8 +499,8 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
499499
}
500500
}
501501

502-
fn check_item(&mut self, item_id: ast::NodeId, item_span: Span) {
503-
let def_id = self.tcx.hir().local_def_id(item_id);
502+
fn check_item(&mut self, item_id: hir::HirId, item_span: Span) {
503+
let def_id = self.tcx.hir().local_def_id_from_hir_id(item_id);
504504
for attr in self.tcx.get_attrs(def_id).iter() {
505505
let assertion = match self.assertion_maybe(item_id, attr) {
506506
Some(a) => a,
@@ -519,15 +519,15 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
519519

520520
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'a, 'tcx> {
521521
fn visit_item(&mut self, item: &'tcx hir::Item) {
522-
self.check_item(item.id, item.span);
522+
self.check_item(item.hir_id, item.span);
523523
}
524524

525525
fn visit_trait_item(&mut self, item: &hir::TraitItem) {
526-
self.check_item(item.id, item.span);
526+
self.check_item(item.hir_id, item.span);
527527
}
528528

529529
fn visit_impl_item(&mut self, item: &hir::ImplItem) {
530-
self.check_item(item.id, item.span);
530+
self.check_item(item.hir_id, item.span);
531531
}
532532
}
533533

0 commit comments

Comments
 (0)