Skip to content

Commit 44a58d4

Browse files
committed
Remove span from hir::Field.
1 parent 61504ae commit 44a58d4

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

src/librustc_ast_lowering/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
13071307
hir_id: self.next_id(f.span),
13081308
ident: f.ident,
13091309
expr: self.lower_expr(&f.expr),
1310-
span: f.span,
13111310
is_shorthand: f.is_shorthand,
13121311
}
13131312
}
@@ -1802,7 +1801,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18021801
}
18031802

18041803
fn field(&mut self, ident: Ident, expr: &'hir hir::Expr<'hir>, span: Span) -> hir::Field<'hir> {
1805-
hir::Field { hir_id: self.next_id(span), ident, span, expr, is_shorthand: false }
1804+
hir::Field { hir_id: self.next_id(span), ident, expr, is_shorthand: false }
18061805
}
18071806

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

src/librustc_hir/hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,6 @@ pub struct Field<'hir> {
11591159
pub hir_id: HirId,
11601160
pub ident: Ident,
11611161
pub expr: &'hir Expr<'hir>,
1162-
pub span: Span,
11631162
pub is_shorthand: bool,
11641163
}
11651164

src/librustc_hir_pretty/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ impl<'a> State<'a> {
11881188
s.print_expr(&field.expr);
11891189
s.end()
11901190
},
1191-
|_, f| f.span,
1191+
|s, f| s.span(f.hir_id),
11921192
);
11931193
match *wth {
11941194
Some(ref expr) => {

src/librustc_lint/types.rs

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

src/librustc_privacy/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,16 +1131,17 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
11311131
.iter()
11321132
.find(|f| self.tcx.field_index(f.hir_id, self.tables) == vf_index);
11331133
let (use_ctxt, span) = match field {
1134-
Some(field) => (field.ident.span, field.span),
1134+
Some(field) => (field.ident.span, self.tcx.hir().span(field.hir_id)),
11351135
None => (base.span, base.span),
11361136
};
11371137
self.check_field(use_ctxt, span, adt, variant_field, true);
11381138
}
11391139
} else {
11401140
for field in fields {
1141+
let field_span = self.tcx.hir().span(field.hir_id);
11411142
let use_ctxt = field.ident.span;
11421143
let index = self.tcx.field_index(field.hir_id, self.tables);
1143-
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
1144+
self.check_field(use_ctxt, field_span, adt, &variant.fields[index], false);
11441145
}
11451146
}
11461147
}

src/librustc_typeck/check/expr.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,17 +1186,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11861186
for field in ast_fields {
11871187
let ident = tcx.adjust_ident(field.ident, variant.def_id);
11881188
let field_type = if let Some((i, v_field)) = remaining_fields.remove(&ident) {
1189-
seen_fields.insert(ident, field.span);
1189+
let field_span = self.tcx.hir().span(field.hir_id);
1190+
seen_fields.insert(ident, field_span);
11901191
self.write_field_index(field.hir_id, i);
11911192

11921193
// We don't look at stability attributes on
11931194
// struct-like enums (yet...), but it's definitely not
11941195
// a bug to have constructed one.
11951196
if adt_kind != AdtKind::Enum {
1196-
tcx.check_stability(v_field.did, Some(expr_id), field.span);
1197+
tcx.check_stability(v_field.did, Some(expr_id), field_span);
11971198
}
11981199

1199-
self.field_ty(field.span, v_field, substs)
1200+
self.field_ty(field_span, v_field, substs)
12001201
} else {
12011202
error_happened = true;
12021203
if let Some(prev_span) = seen_fields.get(&ident) {

0 commit comments

Comments
 (0)