mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-01 20:47:36 +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 {
|
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 {
|
hir::StructField {
|
||||||
span: f.span,
|
span: f.span,
|
||||||
id: node_id,
|
|
||||||
hir_id,
|
hir_id,
|
||||||
ident: match f.ident {
|
ident: match f.ident {
|
||||||
Some(ident) => ident,
|
Some(ident) => ident,
|
||||||
|
@ -2132,7 +2132,6 @@ pub struct StructField {
|
|||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub ident: Ident,
|
pub ident: Ident,
|
||||||
pub vis: Visibility,
|
pub vis: Visibility,
|
||||||
pub id: NodeId,
|
|
||||||
pub hir_id: HirId,
|
pub hir_id: HirId,
|
||||||
pub ty: P<Ty>,
|
pub ty: P<Ty>,
|
||||||
pub attrs: HirVec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
|
@ -838,7 +838,6 @@ impl_stable_hash_for!(struct hir::StructField {
|
|||||||
span,
|
span,
|
||||||
ident -> (ident.name),
|
ident -> (ident.name),
|
||||||
vis,
|
vis,
|
||||||
id,
|
|
||||||
hir_id,
|
hir_id,
|
||||||
ty,
|
ty,
|
||||||
attrs
|
attrs
|
||||||
|
@ -465,7 +465,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
|
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()
|
!field.is_positional()
|
||||||
&& !self.symbol_is_live(field.hir_id)
|
&& !self.symbol_is_live(field.hir_id)
|
||||||
&& !field_type.is_phantom_data()
|
&& !field_type.is_phantom_data()
|
||||||
|
@ -317,10 +317,9 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
|
|||||||
impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
|
impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
|
||||||
fn check_missing_stability(&self, hir_id: HirId, span: Span, name: &str) {
|
fn check_missing_stability(&self, hir_id: HirId, span: Span, name: &str) {
|
||||||
let stab = self.tcx.stability().local_stability(hir_id);
|
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 &&
|
let is_error = !self.tcx.sess.opts.test &&
|
||||||
stab.is_none() &&
|
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 {
|
if is_error {
|
||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
span,
|
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
|
let mut reachable_non_generics: DefIdMap<_> = tcx.reachable_set(LOCAL_CRATE).0
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|&node_id| {
|
.filter_map(|&hir_id| {
|
||||||
// We want to ignore some FFI functions that are not exposed from
|
// We want to ignore some FFI functions that are not exposed from
|
||||||
// this crate. Reachable FFI functions can be lumped into two
|
// this crate. Reachable FFI functions can be lumped into two
|
||||||
// categories:
|
// 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
|
// As a result, if this id is an FFI item (foreign item) then we only
|
||||||
// let it through if it's included statically.
|
// 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(..) => {
|
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) {
|
if tcx.is_statically_included_foreign_item(def_id) {
|
||||||
Some(def_id)
|
Some(def_id)
|
||||||
} else {
|
} else {
|
||||||
@ -105,7 +105,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||||||
node: hir::ImplItemKind::Method(..),
|
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);
|
let generics = tcx.generics_of(def_id);
|
||||||
if !generics.requires_monomorphization(tcx) &&
|
if !generics.requires_monomorphization(tcx) &&
|
||||||
// Functions marked with #[inline] are only ever codegened
|
// 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 {
|
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) {
|
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
|
||||||
!tcx.reachable_set(LOCAL_CRATE).0.contains(&node_id)
|
!tcx.reachable_set(LOCAL_CRATE).0.contains(&hir_id)
|
||||||
} else {
|
} else {
|
||||||
bug!("is_unreachable_local_definition called with non-local DefId: {:?}",
|
bug!("is_unreachable_local_definition called with non-local DefId: {:?}",
|
||||||
def_id)
|
def_id)
|
||||||
|
@ -148,7 +148,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
|
|||||||
hir::ItemKind::Struct(ref struct_def, _) |
|
hir::ItemKind::Struct(ref struct_def, _) |
|
||||||
hir::ItemKind::Union(ref struct_def, _) => {
|
hir::ItemKind::Union(ref struct_def, _) => {
|
||||||
for struct_field in struct_def.fields() {
|
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,
|
self.check_heap_type(cx, struct_field.span,
|
||||||
cx.tcx.type_of(def_id));
|
cx.tcx.type_of(def_id));
|
||||||
}
|
}
|
||||||
@ -560,7 +560,8 @@ impl LintPass for MissingCopyImplementations {
|
|||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
|
||||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
let (def, ty) = match item.node {
|
let (def, ty) = match item.node {
|
||||||
@ -631,7 +632,8 @@ impl LintPass for MissingDebugImplementations {
|
|||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
|
||||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1078,7 +1080,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
|
|||||||
fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) {
|
fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||||
if let hir::ItemKind::Union(ref vdata, _) = item.node {
|
if let hir::ItemKind::Union(ref vdata, _) = item.node {
|
||||||
for field in vdata.fields() {
|
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) {
|
if field_ty.needs_drop(ctx.tcx, ctx.param_env) {
|
||||||
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
|
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
|
||||||
field.span,
|
field.span,
|
||||||
|
@ -1050,7 +1050,7 @@ struct AdtField<'tcx> {
|
|||||||
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
fn non_enum_variant(&self, struct_def: &hir::VariantData) -> AdtVariant<'tcx> {
|
fn non_enum_variant(&self, struct_def: &hir::VariantData) -> AdtVariant<'tcx> {
|
||||||
let fields = struct_def.fields().iter().map(|field| {
|
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,
|
let field_ty = self.normalize_associated_types_in(field.span,
|
||||||
&field_ty);
|
&field_ty);
|
||||||
AdtField { ty: field_ty, span: field.span }
|
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);
|
tcx.predicates_of(def_id);
|
||||||
|
|
||||||
for f in struct_def.fields() {
|
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.generics_of(def_id);
|
||||||
tcx.type_of(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.predicates_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() {
|
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.generics_of(def_id);
|
||||||
tcx.type_of(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.predicates_of(def_id);
|
tcx.predicates_of(def_id);
|
||||||
@ -582,7 +582,7 @@ fn convert_variant<'a, 'tcx>(
|
|||||||
.fields()
|
.fields()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|f| {
|
.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();
|
let dup_span = seen_fields.get(&f.ident.modern()).cloned();
|
||||||
if let Some(prev_span) = dup_span {
|
if let Some(prev_span) = dup_span {
|
||||||
struct_span_err!(
|
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 ty = tcx.type_of(tcx.hir().get_parent_did(node_id));
|
||||||
let inputs = fields
|
let inputs = fields
|
||||||
.iter()
|
.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(
|
ty::Binder::bind(tcx.mk_fn_sig(
|
||||||
inputs,
|
inputs,
|
||||||
ty,
|
ty,
|
||||||
|
@ -2913,14 +2913,16 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
|||||||
|
|
||||||
impl Clean<Item> for hir::StructField {
|
impl Clean<Item> for hir::StructField {
|
||||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||||
|
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
name: Some(self.ident.name).clean(cx),
|
name: Some(self.ident.name).clean(cx),
|
||||||
attrs: self.attrs.clean(cx),
|
attrs: self.attrs.clean(cx),
|
||||||
source: self.span.clean(cx),
|
source: self.span.clean(cx),
|
||||||
visibility: self.vis.clean(cx),
|
visibility: self.vis.clean(cx),
|
||||||
stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)),
|
stability: get_stability(cx, local_did),
|
||||||
deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)),
|
deprecation: get_deprecation(cx, local_did),
|
||||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
def_id: local_did,
|
||||||
inner: StructFieldItem(self.ty.clean(cx)),
|
inner: StructFieldItem(self.ty.clean(cx)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user