Skip to content

Commit 96b8564

Browse files
committed
Remove span from hir::Field.
1 parent 732ae69 commit 96b8564

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
@@ -1556,7 +1556,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
15561556
hir_id: self.next_id(f.span),
15571557
ident: f.ident,
15581558
expr: self.lower_expr(&f.expr),
1559-
span: f.span,
15601559
is_shorthand: f.is_shorthand,
15611560
}
15621561
}
@@ -2048,7 +2047,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
20482047
}
20492048

20502049
fn field(&mut self, ident: Ident, expr: &'hir hir::Expr<'hir>, span: Span) -> hir::Field<'hir> {
2051-
hir::Field { hir_id: self.next_id(span), ident, span, expr, is_shorthand: false }
2050+
hir::Field { hir_id: self.next_id(span), ident, expr, is_shorthand: false }
20522051
}
20532052

20542053
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
@@ -1167,7 +1167,6 @@ pub struct Field<'hir> {
11671167
pub hir_id: HirId,
11681168
pub ident: Ident,
11691169
pub expr: &'hir Expr<'hir>,
1170-
pub span: Span,
11711170
pub is_shorthand: bool,
11721171
}
11731172

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ impl<'a> State<'a> {
11891189
s.print_expr(&field.expr);
11901190
s.end()
11911191
},
1192-
|_, f| f.span,
1192+
|s, f| s.span(f.hir_id),
11931193
);
11941194
match *wth {
11951195
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
@@ -1024,16 +1024,17 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
10241024
self.tcx.field_index(f.hir_id, self.typeck_results()) == vf_index
10251025
});
10261026
let (use_ctxt, span) = match field {
1027-
Some(field) => (field.ident.span, field.span),
1027+
Some(field) => (field.ident.span, self.tcx.hir().span(field.hir_id)),
10281028
None => (base.span, base.span),
10291029
};
10301030
self.check_field(use_ctxt, span, adt, variant_field, true);
10311031
}
10321032
} else {
10331033
for field in fields {
1034+
let field_span = self.tcx.hir().span(field.hir_id);
10341035
let use_ctxt = field.ident.span;
10351036
let index = self.tcx.field_index(field.hir_id, self.typeck_results());
1036-
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
1037+
self.check_field(use_ctxt, field_span, adt, &variant.fields[index], false);
10371038
}
10381039
}
10391040
}

compiler/rustc_typeck/src/check/expr.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,17 +1204,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12041204
for field in ast_fields {
12051205
let ident = tcx.adjust_ident(field.ident, variant.def_id);
12061206
let field_type = if let Some((i, v_field)) = remaining_fields.remove(&ident) {
1207-
seen_fields.insert(ident, field.span);
1207+
let field_span = self.tcx.hir().span(field.hir_id);
1208+
seen_fields.insert(ident, field_span);
12081209
self.write_field_index(field.hir_id, i);
12091210

12101211
// We don't look at stability attributes on
12111212
// struct-like enums (yet...), but it's definitely not
12121213
// a bug to have constructed one.
12131214
if adt_kind != AdtKind::Enum {
1214-
tcx.check_stability(v_field.did, Some(expr_id), field.span);
1215+
tcx.check_stability(v_field.did, Some(expr_id), field_span);
12151216
}
12161217

1217-
self.field_ty(field.span, v_field, substs)
1218+
self.field_ty(field_span, v_field, substs)
12181219
} else {
12191220
error_happened = true;
12201221
if let Some(prev_span) = seen_fields.get(&ident) {

0 commit comments

Comments
 (0)