Skip to content

Commit 0bf0ea2

Browse files
committed
Remove span from hir::StructField.
1 parent dad5ec0 commit 0bf0ea2

File tree

12 files changed

+38
-36
lines changed

12 files changed

+38
-36
lines changed

src/librustc_ast_lowering/item.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
739739
self.lower_ty(&f.ty, ImplTraitContext::disallowed())
740740
};
741741
hir::StructField {
742-
span: f.span,
743742
hir_id: self.lower_node_id(f.id, f.span),
744743
ident: match f.ident {
745744
Some(ident) => ident,

src/librustc_hir/hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,6 @@ impl VisibilityKind<'_> {
23822382

23832383
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
23842384
pub struct StructField<'hir> {
2385-
pub span: Span,
23862385
#[stable_hasher(project(name))]
23872386
pub ident: Ident,
23882387
pub vis: Visibility<'hir>,

src/librustc_hir_pretty/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,8 @@ impl<'a> State<'a> {
897897
if let hir::VariantData::Tuple(..) = struct_def {
898898
self.popen();
899899
self.commasep(Inconsistent, struct_def.fields(), |s, field| {
900-
s.maybe_print_comment(field.span.lo());
900+
let span = s.span(field.hir_id);
901+
s.maybe_print_comment(span.lo());
901902
s.print_outer_attributes(&field.attrs);
902903
s.print_visibility(&field.vis);
903904
s.print_type(&field.ty)
@@ -918,8 +919,9 @@ impl<'a> State<'a> {
918919
self.hardbreak_if_not_bol();
919920

920921
for field in struct_def.fields() {
922+
let span = self.span(field.hir_id);
921923
self.hardbreak_if_not_bol();
922-
self.maybe_print_comment(field.span.lo());
924+
self.maybe_print_comment(span.lo());
923925
self.print_outer_attributes(&field.attrs);
924926
self.print_visibility(&field.vis);
925927
self.print_ident(field.ident);

src/librustc_lint/builtin.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
136136
hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => {
137137
for struct_field in struct_def.fields() {
138138
let def_id = cx.tcx.hir().local_def_id(struct_field.hir_id);
139-
self.check_heap_type(cx, struct_field.span, cx.tcx.type_of(def_id));
139+
let span = cx.tcx.hir().span(struct_field.hir_id);
140+
self.check_heap_type(cx, span, cx.tcx.type_of(def_id));
140141
}
141142
}
142143
_ => (),
@@ -505,14 +506,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
505506

506507
fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, sf: &hir::StructField<'_>) {
507508
if !sf.is_positional() {
508-
self.check_missing_docs_attrs(
509-
cx,
510-
Some(sf.hir_id),
511-
&sf.attrs,
512-
sf.span,
513-
"a",
514-
"struct field",
515-
)
509+
let span = cx.tcx.hir().span(sf.hir_id);
510+
self.check_missing_docs_attrs(cx, Some(sf.hir_id), &sf.attrs, span, "a", "struct field")
516511
}
517512
}
518513

@@ -1025,7 +1020,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnreachablePub {
10251020
}
10261021

10271022
fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &hir::StructField<'_>) {
1028-
self.perform_lint(cx, "field", field.hir_id, &field.vis, field.span, false);
1023+
let span = cx.tcx.hir().span(field.hir_id);
1024+
self.perform_lint(cx, "field", field.hir_id, &field.vis, span, false);
10291025
}
10301026

10311027
fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplItem<'_>) {

src/librustc_middle/hir/map/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
536536
}
537537

538538
fn visit_struct_field(&mut self, field: &'hir StructField<'hir>) {
539-
self.insert(field.span, field.hir_id, Node::Field(field));
539+
self.insert(DUMMY_SP, field.hir_id, Node::Field(field));
540540
self.with_parent(field.hir_id, |this| {
541541
intravisit::walk_struct_field(this, field);
542542
});

src/librustc_passes/dead.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
633633

634634
fn visit_struct_field(&mut self, field: &'tcx hir::StructField<'tcx>) {
635635
if self.should_warn_about_field(&field) {
636-
self.warn_dead_code(field.hir_id, field.span, field.ident.name, "read");
636+
let span = self.tcx.hir().span(field.hir_id);
637+
self.warn_dead_code(field.hir_id, span, field.ident.name, "read");
637638
}
638639
intravisit::walk_struct_field(self, field);
639640
}

src/librustc_passes/stability.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
316316
}
317317

318318
fn visit_struct_field(&mut self, s: &'tcx StructField<'tcx>) {
319-
self.annotate(s.hir_id, &s.attrs, s.span, AnnotationKind::Required, |v| {
319+
let span = self.tcx.hir().span(s.hir_id);
320+
self.annotate(s.hir_id, &s.attrs, span, AnnotationKind::Required, |v| {
320321
intravisit::walk_struct_field(v, s);
321322
});
322323
}
@@ -391,7 +392,8 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
391392
}
392393

393394
fn visit_struct_field(&mut self, s: &'tcx StructField<'tcx>) {
394-
self.check_missing_stability(s.hir_id, s.span);
395+
let span = self.tcx.hir().span(s.hir_id);
396+
self.check_missing_stability(s.hir_id, span);
395397
intravisit::walk_struct_field(self, s);
396398
}
397399

src/librustc_typeck/check/wfcheck.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,10 +1326,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13261326
.iter()
13271327
.map(|field| {
13281328
let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id(field.hir_id));
1329-
let field_ty = self.normalize_associated_types_in(field.span, &field_ty);
1329+
let span = self.tcx.hir().span(field.hir_id);
1330+
let field_ty = self.normalize_associated_types_in(span, &field_ty);
13301331
let field_ty = self.resolve_vars_if_possible(&field_ty);
13311332
debug!("non_enum_variant: type of field {:?} is {:?}", field, field_ty);
1332-
AdtField { ty: field_ty, span: field.span }
1333+
AdtField { ty: field_ty, span }
13331334
})
13341335
.collect();
13351336
AdtVariant { fields, explicit_discr: None }

src/librustc_typeck/collect.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -819,20 +819,15 @@ fn convert_variant(
819819
.iter()
820820
.map(|f| {
821821
let fid = tcx.hir().local_def_id(f.hir_id);
822+
let span = tcx.hir().span(f.hir_id);
822823
let dup_span = seen_fields.get(&f.ident.normalize_to_macros_2_0()).cloned();
823824
if let Some(prev_span) = dup_span {
824-
struct_span_err!(
825-
tcx.sess,
826-
f.span,
827-
E0124,
828-
"field `{}` is already declared",
829-
f.ident
830-
)
831-
.span_label(f.span, "field already declared")
832-
.span_label(prev_span, format!("`{}` first declared here", f.ident))
833-
.emit();
825+
struct_span_err!(tcx.sess, span, E0124, "field `{}` is already declared", f.ident)
826+
.span_label(span, "field already declared")
827+
.span_label(prev_span, format!("`{}` first declared here", f.ident))
828+
.emit();
834829
} else {
835-
seen_fields.insert(f.ident.normalize_to_macros_2_0(), f.span);
830+
seen_fields.insert(f.ident.normalize_to_macros_2_0(), span);
836831
}
837832

838833
ty::FieldDef {

src/librustdoc/clean/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1736,11 +1736,12 @@ impl<'tcx> Clean<Constant> for ty::Const<'tcx> {
17361736
impl Clean<Item> for hir::StructField<'_> {
17371737
fn clean(&self, cx: &DocContext<'_>) -> Item {
17381738
let local_did = cx.tcx.hir().local_def_id(self.hir_id);
1739+
let span = cx.tcx.hir().span(self.hir_id);
17391740

17401741
Item {
17411742
name: Some(self.ident.name).clean(cx),
17421743
attrs: self.attrs.clean(cx),
1743-
source: self.span.clean(cx),
1744+
source: span.clean(cx),
17441745
visibility: self.vis.clean(cx),
17451746
stability: get_stability(cx, local_did.to_def_id()),
17461747
deprecation: get_deprecation(cx, local_did.to_def_id()),

0 commit comments

Comments
 (0)