Skip to content

Remove NodeId from even more HIR nodes #58836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
hir: remove NodeId from StructField
  • Loading branch information
ljedrz committed Mar 2, 2019
commit ae45f170ee0ce7d068b51b14cb2d0685c16327bc
3 changes: 1 addition & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ty>,
pub attrs: HirVec<Attribute>,
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,6 @@ impl_stable_hash_for!(struct hir::StructField {
span,
ident -> (ident.name),
vis,
id,
hir_id,
ty,
attrs
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_codegen_ssa/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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!(
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2913,14 +2913,16 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {

impl Clean<Item> 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)),
}
}
Expand Down