Skip to content

Remove Spans from HIR -- 3/N -- hir::Item #73095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3603d31
Remove useless Clone bound in IndexVec.
cjgillot May 19, 2020
76a36df
Introduce HirIdVec.
cjgillot May 19, 2020
c6acd0f
Collect spans during HIR indexing.
cjgillot May 1, 2020
71b5666
Introduce a query for HIR spans.
cjgillot May 8, 2020
5b5bc8d
Collect spans during lowering.
cjgillot May 1, 2020
6a1537c
Collect spans directly into an IndexVec.
cjgillot May 18, 2020
3640fb3
Directly use span map for indexing.
cjgillot May 1, 2020
1b9ccbf
Don't pass spans in hir::map::blocks.
cjgillot May 2, 2020
9f00730
Add comment.
cjgillot Jun 6, 2020
ff32863
Stop passing the Span in HIR visiting.
cjgillot May 2, 2020
61402a5
Pass HirId in save_analysis.
cjgillot Jun 7, 2020
a1b12d8
Remove span from hir::Param.
cjgillot May 1, 2020
dad5ec0
Remove span from hir::Variant.
cjgillot May 1, 2020
0bf0ea2
Remove span from hir::StructField.
cjgillot May 1, 2020
76f16ed
Remove span from hir::Stmt.
cjgillot May 1, 2020
8197821
Remove span from hir::Block.
cjgillot May 1, 2020
deec340
Remove span from hir::MacroDef.
cjgillot May 2, 2020
7584102
Remove span from hir::GenericParam.
cjgillot May 2, 2020
71c2c92
Remove span from hir::Arm.
cjgillot May 2, 2020
f94dac7
Remove span from hir::FieldPat.
cjgillot May 2, 2020
1f05c3d
Remove span from hir::Local.
cjgillot May 2, 2020
61504ae
Remove span from hir::Pat.
cjgillot May 2, 2020
44a58d4
Remove span from hir::Field.
cjgillot May 2, 2020
415ad17
Remove GenericArg::span.
cjgillot May 3, 2020
ed0b627
Remove Span from hir::TypeBinding.
cjgillot May 8, 2020
56ee3f9
Remove Span from hir::ConstArg.
cjgillot Jun 1, 2020
00ce893
Remove Span from hir::TraitItemRef.
cjgillot Jun 1, 2020
0f31095
Remove Span from hir::ImplItemRef.
cjgillot Jun 1, 2020
312c2fb
Fix fulldeps tests.
cjgillot May 9, 2020
d3a1ecd
Pass HirId in librustc_typeck::check.
cjgillot May 2, 2020
63db483
Pass HirId in librustc_lint.
cjgillot May 2, 2020
066195c
Pass HirId in librustc_passes::stability.
cjgillot May 2, 2020
edbbd56
Remove span from hir::Item.
cjgillot May 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove span from hir::Field.
  • Loading branch information
cjgillot committed Jun 23, 2020
commit 44a58d44b5313b2f60ada84a2e466c206ac72152
3 changes: 1 addition & 2 deletions src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir_id: self.next_id(f.span),
ident: f.ident,
expr: self.lower_expr(&f.expr),
span: f.span,
is_shorthand: f.is_shorthand,
}
}
Expand Down Expand Up @@ -1802,7 +1801,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

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

fn arm(&mut self, pat: &'hir hir::Pat<'hir>, expr: &'hir hir::Expr<'hir>) -> hir::Arm<'hir> {
Expand Down
1 change: 0 additions & 1 deletion src/librustc_hir/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,6 @@ pub struct Field<'hir> {
pub hir_id: HirId,
pub ident: Ident,
pub expr: &'hir Expr<'hir>,
pub span: Span,
pub is_shorthand: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_hir_pretty/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ impl<'a> State<'a> {
s.print_expr(&field.expr);
s.end()
},
|_, f| f.span,
|s, f| s.span(f.hir_id),
);
match *wth {
Some(ref expr) => {
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
if eps[1].expr.hir_id == expr.hir_id && lit_val - 1 == max {
cx.struct_span_lint(OVERFLOWING_LITERALS, parent_expr.span, |lint| {
let mut err = lint.build(&format!("range endpoint is out of range for `{}`", ty));
if let Ok(start) = cx.sess().source_map().span_to_snippet(eps[0].span) {
if let Ok(start) =
cx.sess().source_map().span_to_snippet(cx.tcx.hir().span(eps[0].hir_id))
{
use ast::{LitIntType, LitKind};
// We need to preserve the literal's suffix,
// as it may determine typing information.
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,16 +1131,17 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
.iter()
.find(|f| self.tcx.field_index(f.hir_id, self.tables) == vf_index);
let (use_ctxt, span) = match field {
Some(field) => (field.ident.span, field.span),
Some(field) => (field.ident.span, self.tcx.hir().span(field.hir_id)),
None => (base.span, base.span),
};
self.check_field(use_ctxt, span, adt, variant_field, true);
}
} else {
for field in fields {
let field_span = self.tcx.hir().span(field.hir_id);
let use_ctxt = field.ident.span;
let index = self.tcx.field_index(field.hir_id, self.tables);
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
self.check_field(use_ctxt, field_span, adt, &variant.fields[index], false);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_typeck/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,17 +1186,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for field in ast_fields {
let ident = tcx.adjust_ident(field.ident, variant.def_id);
let field_type = if let Some((i, v_field)) = remaining_fields.remove(&ident) {
seen_fields.insert(ident, field.span);
let field_span = self.tcx.hir().span(field.hir_id);
seen_fields.insert(ident, field_span);
self.write_field_index(field.hir_id, i);

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

self.field_ty(field.span, v_field, substs)
self.field_ty(field_span, v_field, substs)
} else {
error_happened = true;
if let Some(prev_span) = seen_fields.get(&ident) {
Expand Down