Skip to content

Commit ec56b9f

Browse files
committed
Remove span from hir::Field.
1 parent f51da1e commit ec56b9f

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
16661666
hir_id: self.next_id(f.span),
16671667
ident: f.ident,
16681668
expr: self.lower_expr(&f.expr),
1669-
span: f.span,
16701669
is_shorthand: f.is_shorthand,
16711670
}
16721671
}
@@ -2164,7 +2163,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21642163
}
21652164

21662165
fn field(&mut self, ident: Ident, expr: &'hir hir::Expr<'hir>, span: Span) -> hir::Field<'hir> {
2167-
hir::Field { hir_id: self.next_id(span), ident, span, expr, is_shorthand: false }
2166+
hir::Field { hir_id: self.next_id(span), ident, expr, is_shorthand: false }
21682167
}
21692168

21702169
fn arm(&mut self, pat: &'hir hir::Pat<'hir>, expr: &'hir hir::Expr<'hir>) -> hir::Arm<'hir> {

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,6 @@ pub struct Field<'hir> {
11961196
pub hir_id: HirId,
11971197
pub ident: Ident,
11981198
pub expr: &'hir Expr<'hir>,
1199-
pub span: Span,
12001199
pub is_shorthand: bool,
12011200
}
12021201

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ impl<'a> State<'a> {
12401240
s.print_expr(&field.expr);
12411241
s.end()
12421242
},
1243-
|_, f| f.span,
1243+
|s, f| s.span(f.hir_id),
12441244
);
12451245
match *wth {
12461246
Some(ref expr) => {

compiler/rustc_lint/src/types.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ fn lint_overflowing_range_endpoint<'tcx>(
140140
if eps[1].expr.hir_id == expr.hir_id && lit_val - 1 == max {
141141
cx.struct_span_lint(OVERFLOWING_LITERALS, parent_expr.span, |lint| {
142142
let mut err = lint.build(&format!("range endpoint is out of range for `{}`", ty));
143-
if let Ok(start) = cx.sess().source_map().span_to_snippet(eps[0].span) {
143+
if let Ok(start) =
144+
cx.sess().source_map().span_to_snippet(cx.tcx.hir().span(eps[0].hir_id))
145+
{
144146
use ast::{LitIntType, LitKind};
145147
// We need to preserve the literal's suffix,
146148
// as it may determine typing information.

compiler/rustc_privacy/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,16 +1076,17 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
10761076
self.tcx.field_index(f.hir_id, self.typeck_results()) == vf_index
10771077
});
10781078
let (use_ctxt, span) = match field {
1079-
Some(field) => (field.ident.span, field.span),
1079+
Some(field) => (field.ident.span, self.tcx.hir().span(field.hir_id)),
10801080
None => (base.span, base.span),
10811081
};
10821082
self.check_field(use_ctxt, span, adt, variant_field, true);
10831083
}
10841084
} else {
10851085
for field in fields {
1086+
let field_span = self.tcx.hir().span(field.hir_id);
10861087
let use_ctxt = field.ident.span;
10871088
let index = self.tcx.field_index(field.hir_id, self.typeck_results());
1088-
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
1089+
self.check_field(use_ctxt, field_span, adt, &variant.fields[index], false);
10891090
}
10901091
}
10911092
}

compiler/rustc_typeck/src/check/expr.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,17 +1266,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12661266
for field in ast_fields {
12671267
let ident = tcx.adjust_ident(field.ident, variant.def_id);
12681268
let field_type = if let Some((i, v_field)) = remaining_fields.remove(&ident) {
1269-
seen_fields.insert(ident, field.span);
1269+
let field_span = self.tcx.hir().span(field.hir_id);
1270+
seen_fields.insert(ident, field_span);
12701271
self.write_field_index(field.hir_id, i);
12711272

12721273
// We don't look at stability attributes on
12731274
// struct-like enums (yet...), but it's definitely not
12741275
// a bug to have constructed one.
12751276
if adt_kind != AdtKind::Enum {
1276-
tcx.check_stability(v_field.did, Some(expr_id), field.span);
1277+
tcx.check_stability(v_field.did, Some(expr_id), field_span);
12771278
}
12781279

1279-
self.field_ty(field.span, v_field, substs)
1280+
self.field_ty(field_span, v_field, substs)
12801281
} else {
12811282
error_happened = true;
12821283
if let Some(prev_span) = seen_fields.get(&ident) {

0 commit comments

Comments
 (0)