diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index a97ea7da7f19c..b854cd4af1b59 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2743,11 +2743,10 @@ impl<'a> LoweringContext<'a> { } fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::StructField { - let LoweredNodeId { node_id, hir_id } = self.lower_node_id(f.id); + let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(f.id); hir::StructField { span: f.span, - id: node_id, hir_id, ident: match f.ident { Some(ident) => ident, diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 3ba4efba9186c..fa0487bbc9d48 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2132,7 +2132,6 @@ pub struct StructField { pub span: Span, pub ident: Ident, pub vis: Visibility, - pub id: NodeId, pub hir_id: HirId, pub ty: P, pub attrs: HirVec, diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index af1cce5e35454..718e828e601df 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -838,7 +838,6 @@ impl_stable_hash_for!(struct hir::StructField { span, ident -> (ident.name), vis, - id, hir_id, ty, attrs diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 3b607127d8628..d94a6eb8804b8 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -465,7 +465,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { } fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool { - let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.id)); + let field_type = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id)); !field.is_positional() && !self.symbol_is_live(field.hir_id) && !field_type.is_phantom_data() diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 3c1b49e2dde6c..8b5d70d834d9f 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -317,10 +317,9 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> { impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> { fn check_missing_stability(&self, hir_id: HirId, span: Span, name: &str) { let stab = self.tcx.stability().local_stability(hir_id); - let node_id = self.tcx.hir().hir_to_node_id(hir_id); let is_error = !self.tcx.sess.opts.test && stab.is_none() && - self.access_levels.is_reachable(node_id); + self.access_levels.is_reachable(self.tcx.hir().hir_to_node_id(hir_id)); if is_error { self.tcx.sess.span_err( span, diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index 4b01e264f19ed..7da28c19d2412 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -69,7 +69,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut reachable_non_generics: DefIdMap<_> = tcx.reachable_set(LOCAL_CRATE).0 .iter() - .filter_map(|&node_id| { + .filter_map(|&hir_id| { // We want to ignore some FFI functions that are not exposed from // this crate. Reachable FFI functions can be lumped into two // categories: @@ -83,9 +83,9 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // // As a result, if this id is an FFI item (foreign item) then we only // let it through if it's included statically. - match tcx.hir().get(node_id) { + match tcx.hir().get_by_hir_id(hir_id) { Node::ForeignItem(..) => { - let def_id = tcx.hir().local_def_id(node_id); + let def_id = tcx.hir().local_def_id_from_hir_id(hir_id); if tcx.is_statically_included_foreign_item(def_id) { Some(def_id) } else { @@ -105,7 +105,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node: hir::ImplItemKind::Method(..), .. }) => { - let def_id = tcx.hir().local_def_id(node_id); + let def_id = tcx.hir().local_def_id_from_hir_id(hir_id); let generics = tcx.generics_of(def_id); if !generics.requires_monomorphization(tcx) && // Functions marked with #[inline] are only ever codegened @@ -343,8 +343,8 @@ fn upstream_monomorphizations_for_provider<'a, 'tcx>( } fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> bool { - if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { - !tcx.reachable_set(LOCAL_CRATE).0.contains(&node_id) + if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) { + !tcx.reachable_set(LOCAL_CRATE).0.contains(&hir_id) } else { bug!("is_unreachable_local_definition called with non-local DefId: {:?}", def_id) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 4d484a64f47df..e540a21c2fda9 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -148,7 +148,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => { for struct_field in struct_def.fields() { - let def_id = cx.tcx.hir().local_def_id(struct_field.id); + let def_id = cx.tcx.hir().local_def_id_from_hir_id(struct_field.hir_id); self.check_heap_type(cx, struct_field.span, cx.tcx.type_of(def_id)); } @@ -560,7 +560,8 @@ impl LintPass for MissingCopyImplementations { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations { fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { - if !cx.access_levels.is_reachable(item.id) { + let node_id = cx.tcx.hir().hir_to_node_id(item.hir_id); + if !cx.access_levels.is_reachable(node_id) { return; } let (def, ty) = match item.node { @@ -631,7 +632,8 @@ impl LintPass for MissingDebugImplementations { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { - if !cx.access_levels.is_reachable(item.id) { + let node_id = cx.tcx.hir().hir_to_node_id(item.hir_id); + if !cx.access_levels.is_reachable(node_id) { return; } @@ -1078,7 +1080,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields { fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) { if let hir::ItemKind::Union(ref vdata, _) = item.node { for field in vdata.fields() { - let field_ty = ctx.tcx.type_of(ctx.tcx.hir().local_def_id(field.id)); + let field_ty = ctx.tcx.type_of( + ctx.tcx.hir().local_def_id_from_hir_id(field.hir_id)); if field_ty.needs_drop(ctx.tcx, ctx.param_env) { ctx.span_lint(UNIONS_WITH_DROP_FIELDS, field.span, diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index b7c862a89a1b4..51a971823afb8 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -1050,7 +1050,7 @@ struct AdtField<'tcx> { impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn non_enum_variant(&self, struct_def: &hir::VariantData) -> AdtVariant<'tcx> { let fields = struct_def.fields().iter().map(|field| { - let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id(field.id)); + let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id)); let field_ty = self.normalize_associated_types_in(field.span, &field_ty); AdtField { ty: field_ty, span: field.span } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 16102ad4cde30..38150192886b1 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -447,7 +447,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { tcx.predicates_of(def_id); for f in struct_def.fields() { - let def_id = tcx.hir().local_def_id(f.id); + let def_id = tcx.hir().local_def_id_from_hir_id(f.hir_id); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); @@ -555,7 +555,7 @@ fn convert_enum_variant_types<'a, 'tcx>( ); for f in variant.node.data.fields() { - let def_id = tcx.hir().local_def_id(f.id); + let def_id = tcx.hir().local_def_id_from_hir_id(f.hir_id); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); @@ -582,7 +582,7 @@ fn convert_variant<'a, 'tcx>( .fields() .iter() .map(|f| { - let fid = tcx.hir().local_def_id(f.id); + let fid = tcx.hir().local_def_id_from_hir_id(f.hir_id); let dup_span = seen_fields.get(&f.ident.modern()).cloned(); if let Some(prev_span) = dup_span { struct_span_err!( @@ -1577,7 +1577,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig let ty = tcx.type_of(tcx.hir().get_parent_did(node_id)); let inputs = fields .iter() - .map(|f| tcx.type_of(tcx.hir().local_def_id(f.id))); + .map(|f| tcx.type_of(tcx.hir().local_def_id_from_hir_id(f.hir_id))); ty::Binder::bind(tcx.mk_fn_sig( inputs, ty, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index d88d0dab4f0eb..c39bd13bc3a55 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2913,14 +2913,16 @@ impl<'tcx> Clean for Ty<'tcx> { impl Clean for hir::StructField { fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item { + let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id); + Item { name: Some(self.ident.name).clean(cx), attrs: self.attrs.clean(cx), source: self.span.clean(cx), visibility: self.vis.clean(cx), - stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)), - deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)), - def_id: cx.tcx.hir().local_def_id(self.id), + stability: get_stability(cx, local_did), + deprecation: get_deprecation(cx, local_did), + def_id: local_did, inner: StructFieldItem(self.ty.clean(cx)), } }