mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-30 12:07:40 +00:00
hir: remove NodeId from StructField
This commit is contained in:
parent
7e277d96fe
commit
ae45f170ee
@ -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,
|
||||
|
@ -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>,
|
||||
|
@ -838,7 +838,6 @@ impl_stable_hash_for!(struct hir::StructField {
|
||||
span,
|
||||
ident -> (ident.name),
|
||||
vis,
|
||||
id,
|
||||
hir_id,
|
||||
ty,
|
||||
attrs
|
||||
|
@ -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()
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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 }
|
||||
|
@ -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,
|
||||
|
@ -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)),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user