Skip to content

Commit 3c25193

Browse files
committed
hir: remove NodeId from ForeignItem
1 parent ae45f17 commit 3c25193

File tree

12 files changed

+24
-22
lines changed

12 files changed

+24
-22
lines changed

src/librustc/hir/lowering.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3551,7 +3551,6 @@ impl<'a> LoweringContext<'a> {
35513551
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(i.id);
35523552
let def_id = self.resolver.definitions().local_def_id(node_id);
35533553
hir::ForeignItem {
3554-
id: node_id,
35553554
hir_id,
35563555
ident: i.ident,
35573556
attrs: self.lower_attrs(&i.attrs),

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl<'hir> Map<'hir> {
341341
}
342342
}
343343
Node::ForeignItem(item) => {
344-
let def_id = self.local_def_id(item.id);
344+
let def_id = self.local_def_id_from_hir_id(item.hir_id);
345345
match item.node {
346346
ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)),
347347
ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)),

src/librustc/hir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,6 @@ pub struct ForeignItem {
23782378
pub ident: Ident,
23792379
pub attrs: HirVec<Attribute>,
23802380
pub node: ForeignItemKind,
2381-
pub id: NodeId,
23822381
pub hir_id: HirId,
23832382
pub span: Span,
23842383
pub vis: Visibility,

src/librustc/ich/impls_hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,6 @@ impl_stable_hash_for!(struct hir::ForeignItem {
931931
ident -> (ident.name),
932932
attrs,
933933
node,
934-
id,
935934
hir_id,
936935
span,
937936
vis

src/librustc_lint/types.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
762762
}
763763
}
764764

765-
fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) {
766-
let def_id = self.cx.tcx.hir().local_def_id(id);
765+
fn check_foreign_fn(&mut self, id: hir::HirId, decl: &hir::FnDecl) {
766+
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(id);
767767
let sig = self.cx.tcx.fn_sig(def_id);
768768
let sig = self.cx.tcx.erase_late_bound_regions(&sig);
769769
let inputs = if sig.c_variadic {
@@ -786,8 +786,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
786786
}
787787
}
788788

789-
fn check_foreign_static(&mut self, id: ast::NodeId, span: Span) {
790-
let def_id = self.cx.tcx.hir().local_def_id(id);
789+
fn check_foreign_static(&mut self, id: hir::HirId, span: Span) {
790+
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(id);
791791
let ty = self.cx.tcx.type_of(def_id);
792792
self.check_type_for_ffi_and_report_errors(span, ty);
793793
}
@@ -809,14 +809,14 @@ impl LintPass for ImproperCTypes {
809809
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
810810
fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::ForeignItem) {
811811
let mut vis = ImproperCTypesVisitor { cx };
812-
let abi = cx.tcx.hir().get_foreign_abi(it.id);
812+
let abi = cx.tcx.hir().get_foreign_abi_by_hir_id(it.hir_id);
813813
if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic {
814814
match it.node {
815815
hir::ForeignItemKind::Fn(ref decl, _, _) => {
816-
vis.check_foreign_fn(it.id, decl);
816+
vis.check_foreign_fn(it.hir_id, decl);
817817
}
818818
hir::ForeignItemKind::Static(ref ty, _) => {
819-
vis.check_foreign_static(it.id, ty.span);
819+
vis.check_foreign_static(it.hir_id, ty.span);
820820
}
821821
hir::ForeignItemKind::Type => ()
822822
}

src/librustc_metadata/encoder.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
11611161
hir::ItemKind::ForeignMod(ref fm) => {
11621162
self.lazy_seq(fm.items
11631163
.iter()
1164-
.map(|foreign_item| tcx.hir().local_def_id(foreign_item.id).index))
1164+
.map(|foreign_item| tcx.hir().local_def_id_from_hir_id(
1165+
foreign_item.hir_id).index))
11651166
}
11661167
hir::ItemKind::Enum(..) => {
11671168
let def = self.tcx.adt_def(def_id);
@@ -1607,9 +1608,11 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
16071608
hir::ForeignItemKind::Type => EntryKind::ForeignType,
16081609
};
16091610

1611+
let node_id = self.tcx.hir().hir_to_node_id(nitem.hir_id);
1612+
16101613
Entry {
16111614
kind,
1612-
visibility: self.lazy(&ty::Visibility::from_hir(&nitem.vis, nitem.id, tcx)),
1615+
visibility: self.lazy(&ty::Visibility::from_hir(&nitem.vis, node_id, tcx)),
16131616
span: self.lazy(&nitem.span),
16141617
attributes: self.encode_attributes(&nitem.attrs),
16151618
children: LazySeq::empty(),
@@ -1655,7 +1658,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
16551658
}
16561659
fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem) {
16571660
intravisit::walk_foreign_item(self, ni);
1658-
let def_id = self.index.tcx.hir().local_def_id(ni.id);
1661+
let def_id = self.index.tcx.hir().local_def_id_from_hir_id(ni.hir_id);
16591662
self.index.record(def_id,
16601663
IsolatedEncoder::encode_info_for_foreign_item,
16611664
(def_id, ni));

src/librustc_metadata/foreign_modules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> {
2525
};
2626

2727
let foreign_items = fm.items.iter()
28-
.map(|it| self.tcx.hir().local_def_id(it.id))
28+
.map(|it| self.tcx.hir().local_def_id_from_hir_id(it.hir_id))
2929
.collect();
3030
self.modules.push(ForeignModule {
3131
foreign_items,

src/librustc_typeck/check/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn equate_intrinsic_type<'a, 'tcx>(
2222
inputs: Vec<Ty<'tcx>>,
2323
output: Ty<'tcx>,
2424
) {
25-
let def_id = tcx.hir().local_def_id(it.id);
25+
let def_id = tcx.hir().local_def_id_from_hir_id(it.hir_id);
2626

2727
match it.node {
2828
hir::ForeignItemKind::Fn(..) => {}

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite
14071407
}
14081408
} else {
14091409
for item in &m.items {
1410-
let generics = tcx.generics_of(tcx.hir().local_def_id(item.id));
1410+
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(item.hir_id));
14111411
if generics.params.len() - generics.own_counts().lifetimes != 0 {
14121412
let mut err = struct_span_err!(
14131413
tcx.sess,

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
409409
| hir::ItemKind::GlobalAsm(_) => {}
410410
hir::ItemKind::ForeignMod(ref foreign_mod) => {
411411
for item in &foreign_mod.items {
412-
let def_id = tcx.hir().local_def_id(item.id);
412+
let def_id = tcx.hir().local_def_id_from_hir_id(item.hir_id);
413413
tcx.generics_of(def_id);
414414
tcx.type_of(def_id);
415415
tcx.predicates_of(def_id);

0 commit comments

Comments
 (0)