Skip to content

Commit 37ea837

Browse files
committed
compiler: Lower fn call arg spans down to MIR
To enable improved accuracy of diagnostics in upcoming commits.
1 parent cf21a08 commit 37ea837

File tree

25 files changed

+72
-17
lines changed

25 files changed

+72
-17
lines changed

compiler/rustc_borrowck/src/invalidation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
125125
TerminatorKind::Call {
126126
func,
127127
args,
128+
arg_spans: _,
128129
destination,
129130
target: _,
130131
unwind: _,

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro
707707
TerminatorKind::Call {
708708
func,
709709
args,
710+
arg_spans: _,
710711
destination,
711712
target: _,
712713
unwind: _,

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
425425
TerminatorKind::Call {
426426
func,
427427
args,
428+
arg_spans: _,
428429
destination,
429430
target,
430431
fn_span,

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12481248
mir::TerminatorKind::Call {
12491249
ref func,
12501250
ref args,
1251+
arg_spans: _,
12511252
destination,
12521253
target,
12531254
unwind,

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
115115
Call {
116116
ref func,
117117
ref args,
118+
arg_spans: _,
118119
destination,
119120
target,
120121
unwind,

compiler/rustc_const_eval/src/transform/promote_consts.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,12 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
800800

801801
match terminator.kind {
802802
TerminatorKind::Call {
803-
mut func, mut args, call_source: desugar, fn_span, ..
803+
mut func,
804+
mut args,
805+
arg_spans,
806+
call_source: desugar,
807+
fn_span,
808+
..
804809
} => {
805810
self.visit_operand(&mut func, loc);
806811
for arg in &mut args {
@@ -814,6 +819,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
814819
kind: TerminatorKind::Call {
815820
func,
816821
args,
822+
arg_spans,
817823
unwind: UnwindAction::Continue,
818824
destination: Place::from(new_temp),
819825
target: Some(new_target),

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,13 +1568,13 @@ mod size_asserts {
15681568
use super::*;
15691569
use rustc_data_structures::static_assert_size;
15701570
// tidy-alphabetical-start
1571-
static_assert_size!(BasicBlockData<'_>, 136);
1571+
static_assert_size!(BasicBlockData<'_>, 160);
15721572
static_assert_size!(LocalDecl<'_>, 40);
15731573
static_assert_size!(SourceScopeData<'_>, 72);
15741574
static_assert_size!(Statement<'_>, 32);
15751575
static_assert_size!(StatementKind<'_>, 16);
1576-
static_assert_size!(Terminator<'_>, 104);
1577-
static_assert_size!(TerminatorKind<'_>, 88);
1576+
static_assert_size!(Terminator<'_>, 128);
1577+
static_assert_size!(TerminatorKind<'_>, 112);
15781578
static_assert_size!(VarDebugInfo<'_>, 88);
15791579
// tidy-alphabetical-end
15801580
}

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,9 @@ pub enum TerminatorKind<'tcx> {
671671
/// This allows the memory occupied by "by-value" arguments to be
672672
/// reused across function calls without duplicating the contents.
673673
args: Vec<Operand<'tcx>>,
674+
/// The spans of the args
675+
/// (e.g. `a` and `b` in `x.foo(a, b)`).
676+
arg_spans: Vec<Span>,
674677
/// Where the returned value will be written
675678
destination: Place<'tcx>,
676679
/// Where to go after this call returns. If none, the call necessarily diverges.

compiler/rustc_middle/src/mir/terminator.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -520,13 +520,20 @@ impl<'tcx> TerminatorKind<'tcx> {
520520
}
521521
}
522522

523-
Call { unwind, destination, target, func: _, args: _, fn_span: _, call_source: _ } => {
524-
TerminatorEdges::AssignOnReturn {
525-
return_: target,
526-
cleanup: unwind.cleanup_block(),
527-
place: CallReturnPlaces::Call(destination),
528-
}
529-
}
523+
Call {
524+
unwind,
525+
destination,
526+
target,
527+
func: _,
528+
args: _,
529+
fn_span: _,
530+
arg_spans: _,
531+
call_source: _,
532+
} => TerminatorEdges::AssignOnReturn {
533+
return_: target,
534+
cleanup: unwind.cleanup_block(),
535+
place: CallReturnPlaces::Call(destination),
536+
},
530537

531538
InlineAsm {
532539
template: _,

compiler/rustc_middle/src/mir/visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ macro_rules! make_mir_visitor {
518518
TerminatorKind::Call {
519519
func,
520520
args,
521+
arg_spans: _,
521522
destination,
522523
target: _,
523524
unwind: _,

0 commit comments

Comments
 (0)