Skip to content

Commit ae45f17

Browse files
committed
hir: remove NodeId from StructField
1 parent 7e277d9 commit ae45f17

File tree

10 files changed

+26
-25
lines changed

10 files changed

+26
-25
lines changed

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,11 +2743,10 @@ impl<'a> LoweringContext<'a> {
27432743
}
27442744

27452745
fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::StructField {
2746-
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(f.id);
2746+
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(f.id);
27472747

27482748
hir::StructField {
27492749
span: f.span,
2750-
id: node_id,
27512750
hir_id,
27522751
ident: match f.ident {
27532752
Some(ident) => ident,

src/librustc/hir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,6 @@ pub struct StructField {
21322132
pub span: Span,
21332133
pub ident: Ident,
21342134
pub vis: Visibility,
2135-
pub id: NodeId,
21362135
pub hir_id: HirId,
21372136
pub ty: P<Ty>,
21382137
pub attrs: HirVec<Attribute>,

src/librustc/ich/impls_hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,6 @@ impl_stable_hash_for!(struct hir::StructField {
838838
span,
839839
ident -> (ident.name),
840840
vis,
841-
id,
842841
hir_id,
843842
ty,
844843
attrs

src/librustc/middle/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
465465
}
466466

467467
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
468-
let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.id));
468+
let field_type = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id));
469469
!field.is_positional()
470470
&& !self.symbol_is_live(field.hir_id)
471471
&& !field_type.is_phantom_data()

src/librustc/middle/stability.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,9 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
317317
impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
318318
fn check_missing_stability(&self, hir_id: HirId, span: Span, name: &str) {
319319
let stab = self.tcx.stability().local_stability(hir_id);
320-
let node_id = self.tcx.hir().hir_to_node_id(hir_id);
321320
let is_error = !self.tcx.sess.opts.test &&
322321
stab.is_none() &&
323-
self.access_levels.is_reachable(node_id);
322+
self.access_levels.is_reachable(self.tcx.hir().hir_to_node_id(hir_id));
324323
if is_error {
325324
self.tcx.sess.span_err(
326325
span,

src/librustc_codegen_ssa/back/symbol_export.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
6969

7070
let mut reachable_non_generics: DefIdMap<_> = tcx.reachable_set(LOCAL_CRATE).0
7171
.iter()
72-
.filter_map(|&node_id| {
72+
.filter_map(|&hir_id| {
7373
// We want to ignore some FFI functions that are not exposed from
7474
// this crate. Reachable FFI functions can be lumped into two
7575
// categories:
@@ -83,9 +83,9 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
8383
//
8484
// As a result, if this id is an FFI item (foreign item) then we only
8585
// let it through if it's included statically.
86-
match tcx.hir().get(node_id) {
86+
match tcx.hir().get_by_hir_id(hir_id) {
8787
Node::ForeignItem(..) => {
88-
let def_id = tcx.hir().local_def_id(node_id);
88+
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
8989
if tcx.is_statically_included_foreign_item(def_id) {
9090
Some(def_id)
9191
} else {
@@ -105,7 +105,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
105105
node: hir::ImplItemKind::Method(..),
106106
..
107107
}) => {
108-
let def_id = tcx.hir().local_def_id(node_id);
108+
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
109109
let generics = tcx.generics_of(def_id);
110110
if !generics.requires_monomorphization(tcx) &&
111111
// Functions marked with #[inline] are only ever codegened
@@ -343,8 +343,8 @@ fn upstream_monomorphizations_for_provider<'a, 'tcx>(
343343
}
344344

345345
fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> bool {
346-
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
347-
!tcx.reachable_set(LOCAL_CRATE).0.contains(&node_id)
346+
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
347+
!tcx.reachable_set(LOCAL_CRATE).0.contains(&hir_id)
348348
} else {
349349
bug!("is_unreachable_local_definition called with non-local DefId: {:?}",
350350
def_id)

src/librustc_lint/builtin.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
148148
hir::ItemKind::Struct(ref struct_def, _) |
149149
hir::ItemKind::Union(ref struct_def, _) => {
150150
for struct_field in struct_def.fields() {
151-
let def_id = cx.tcx.hir().local_def_id(struct_field.id);
151+
let def_id = cx.tcx.hir().local_def_id_from_hir_id(struct_field.hir_id);
152152
self.check_heap_type(cx, struct_field.span,
153153
cx.tcx.type_of(def_id));
154154
}
@@ -560,7 +560,8 @@ impl LintPass for MissingCopyImplementations {
560560

561561
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
562562
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
563-
if !cx.access_levels.is_reachable(item.id) {
563+
let node_id = cx.tcx.hir().hir_to_node_id(item.hir_id);
564+
if !cx.access_levels.is_reachable(node_id) {
564565
return;
565566
}
566567
let (def, ty) = match item.node {
@@ -631,7 +632,8 @@ impl LintPass for MissingDebugImplementations {
631632

632633
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
633634
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
634-
if !cx.access_levels.is_reachable(item.id) {
635+
let node_id = cx.tcx.hir().hir_to_node_id(item.hir_id);
636+
if !cx.access_levels.is_reachable(node_id) {
635637
return;
636638
}
637639

@@ -1078,7 +1080,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
10781080
fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) {
10791081
if let hir::ItemKind::Union(ref vdata, _) = item.node {
10801082
for field in vdata.fields() {
1081-
let field_ty = ctx.tcx.type_of(ctx.tcx.hir().local_def_id(field.id));
1083+
let field_ty = ctx.tcx.type_of(
1084+
ctx.tcx.hir().local_def_id_from_hir_id(field.hir_id));
10821085
if field_ty.needs_drop(ctx.tcx, ctx.param_env) {
10831086
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
10841087
field.span,

src/librustc_typeck/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ struct AdtField<'tcx> {
10501050
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
10511051
fn non_enum_variant(&self, struct_def: &hir::VariantData) -> AdtVariant<'tcx> {
10521052
let fields = struct_def.fields().iter().map(|field| {
1053-
let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id(field.id));
1053+
let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id));
10541054
let field_ty = self.normalize_associated_types_in(field.span,
10551055
&field_ty);
10561056
AdtField { ty: field_ty, span: field.span }

src/librustc_typeck/collect.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
447447
tcx.predicates_of(def_id);
448448

449449
for f in struct_def.fields() {
450-
let def_id = tcx.hir().local_def_id(f.id);
450+
let def_id = tcx.hir().local_def_id_from_hir_id(f.hir_id);
451451
tcx.generics_of(def_id);
452452
tcx.type_of(def_id);
453453
tcx.predicates_of(def_id);
@@ -555,7 +555,7 @@ fn convert_enum_variant_types<'a, 'tcx>(
555555
);
556556

557557
for f in variant.node.data.fields() {
558-
let def_id = tcx.hir().local_def_id(f.id);
558+
let def_id = tcx.hir().local_def_id_from_hir_id(f.hir_id);
559559
tcx.generics_of(def_id);
560560
tcx.type_of(def_id);
561561
tcx.predicates_of(def_id);
@@ -582,7 +582,7 @@ fn convert_variant<'a, 'tcx>(
582582
.fields()
583583
.iter()
584584
.map(|f| {
585-
let fid = tcx.hir().local_def_id(f.id);
585+
let fid = tcx.hir().local_def_id_from_hir_id(f.hir_id);
586586
let dup_span = seen_fields.get(&f.ident.modern()).cloned();
587587
if let Some(prev_span) = dup_span {
588588
struct_span_err!(
@@ -1577,7 +1577,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig
15771577
let ty = tcx.type_of(tcx.hir().get_parent_did(node_id));
15781578
let inputs = fields
15791579
.iter()
1580-
.map(|f| tcx.type_of(tcx.hir().local_def_id(f.id)));
1580+
.map(|f| tcx.type_of(tcx.hir().local_def_id_from_hir_id(f.hir_id)));
15811581
ty::Binder::bind(tcx.mk_fn_sig(
15821582
inputs,
15831583
ty,

src/librustdoc/clean/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,14 +2913,16 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
29132913

29142914
impl Clean<Item> for hir::StructField {
29152915
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
2916+
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
2917+
29162918
Item {
29172919
name: Some(self.ident.name).clean(cx),
29182920
attrs: self.attrs.clean(cx),
29192921
source: self.span.clean(cx),
29202922
visibility: self.vis.clean(cx),
2921-
stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)),
2922-
deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)),
2923-
def_id: cx.tcx.hir().local_def_id(self.id),
2923+
stability: get_stability(cx, local_did),
2924+
deprecation: get_deprecation(cx, local_did),
2925+
def_id: local_did,
29242926
inner: StructFieldItem(self.ty.clean(cx)),
29252927
}
29262928
}

0 commit comments

Comments
 (0)