Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 9f62d5c

Browse files
committed
Make TerminatorKind::Call::func Spanned build
To make review easier, this commit does not make any semantic changes. It only makes the previous commit build.
1 parent 0d353cd commit 9f62d5c

File tree

44 files changed

+128
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+128
-143
lines changed

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
554554
&block.terminator().kind
555555
{
556556
// Just point to the function, to reduce the chance of overlapping spans.
557-
let function_span = match func {
557+
let function_span = match &func.node {
558558
Operand::Constant(c) => c.span,
559559
Operand::Copy(place) | Operand::Move(place) => {
560560
if let Some(l) = place.as_local() {

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
103103
let terminator = self.body[location.block].terminator();
104104
debug!("add_moved_or_invoked_closure_note: terminator={:?}", terminator);
105105
if let TerminatorKind::Call {
106-
func: Operand::Constant(box ConstOperand { const_, .. }),
106+
func: Spanned { node: Operand::Constant(box ConstOperand { const_, .. }), .. },
107107
args,
108108
..
109109
} = &terminator.kind
@@ -430,7 +430,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
430430
}) = &bbd.terminator
431431
{
432432
if let Some(source) =
433-
BorrowedContentSource::from_call(func.ty(self.body, tcx), tcx)
433+
BorrowedContentSource::from_call(func.node.ty(self.body, tcx), tcx)
434434
{
435435
return source;
436436
}
@@ -855,7 +855,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
855855
debug!("move_spans: target_temp = {:?}", target_temp);
856856

857857
if let Some(Terminator {
858-
kind: TerminatorKind::Call { fn_span, call_source, .. }, ..
858+
kind: TerminatorKind::Call { func: Spanned { span: fn_span, .. }, call_source, .. },
859+
..
859860
}) = &self.body[location.block].terminator
860861
{
861862
let Some((method_did, method_args)) = rustc_middle::util::find_self_call(

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,8 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro
699699
target: _,
700700
unwind: _,
701701
call_source: _,
702-
fn_span: _,
703702
} => {
704-
self.consume_operand(loc, (func, span), flow_state);
703+
self.consume_operand(loc, (&func.node, span), flow_state);
705704
for arg in args {
706705
self.consume_operand(loc, (&arg.node, arg.span), flow_state);
707706
}

compiler/rustc_borrowck/src/polonius/loan_invalidations.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ impl<'cx, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'cx, 'tcx> {
116116
target: _,
117117
unwind: _,
118118
call_source: _,
119-
fn_span: _,
120119
} => {
121-
self.consume_operand(location, func);
120+
self.consume_operand(location, &func.node);
122121
for arg in args {
123122
self.consume_operand(location, &arg.node);
124123
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,12 +1367,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13671367
// FIXME: check the values
13681368
}
13691369
TerminatorKind::Call { func, args, destination, call_source, target, .. } => {
1370-
self.check_operand(func, term_location);
1370+
self.check_operand(&func.node, term_location);
13711371
for arg in args {
13721372
self.check_operand(&arg.node, term_location);
13731373
}
13741374

1375-
let func_ty = func.ty(body, tcx);
1375+
let func_ty = func.node.ty(body, tcx);
13761376
debug!("func_ty.kind: {:?}", func_ty.kind());
13771377

13781378
let sig = match func_ty.kind() {
@@ -1441,7 +1441,15 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14411441
.add_location(region_vid, term_location);
14421442
}
14431443

1444-
self.check_call_inputs(body, term, func, &sig, args, term_location, *call_source);
1444+
self.check_call_inputs(
1445+
body,
1446+
term,
1447+
&func.node,
1448+
&sig,
1449+
args,
1450+
term_location,
1451+
*call_source,
1452+
);
14451453
}
14461454
TerminatorKind::Assert { cond, msg, .. } => {
14471455
self.check_operand(cond, term_location);

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -421,20 +421,12 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
421421
switch.emit(&mut fx.bcx, discr, otherwise_block);
422422
}
423423
}
424-
TerminatorKind::Call {
425-
func,
426-
args,
427-
destination,
428-
target,
429-
fn_span,
430-
unwind: _,
431-
call_source: _,
432-
} => {
424+
TerminatorKind::Call { func, args, destination, target, unwind: _, call_source: _ } => {
433425
fx.tcx.prof.generic_activity("codegen call").run(|| {
434426
crate::abi::codegen_terminator_call(
435427
fx,
436-
mir::SourceInfo { span: *fn_span, ..source_info },
437-
func,
428+
mir::SourceInfo { span: func.span, ..source_info },
429+
&func.node,
438430
args,
439431
*destination,
440432
*target,

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -741,19 +741,18 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
741741
helper: TerminatorCodegenHelper<'tcx>,
742742
bx: &mut Bx,
743743
terminator: &mir::Terminator<'tcx>,
744-
func: &mir::Operand<'tcx>,
744+
func: &Spanned<mir::Operand<'tcx>>,
745745
args: &[Spanned<mir::Operand<'tcx>>],
746746
destination: mir::Place<'tcx>,
747747
target: Option<mir::BasicBlock>,
748748
unwind: mir::UnwindAction,
749-
fn_span: Span,
750749
mergeable_succ: bool,
751750
) -> MergingSucc {
752751
let source_info = terminator.source_info;
753752
let span = source_info.span;
754753

755754
// Create the callee. This is a fn ptr or zero-sized and hence a kind of scalar.
756-
let callee = self.codegen_operand(bx, func);
755+
let callee = self.codegen_operand(bx, &func.node);
757756

758757
let (instance, mut llfn) = match *callee.layout.ty.kind() {
759758
ty::FnDef(def_id, args) => (
@@ -829,8 +828,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
829828

830829
if intrinsic == Some(sym::caller_location) {
831830
return if let Some(target) = target {
832-
let location =
833-
self.get_caller_location(bx, mir::SourceInfo { span: fn_span, ..source_info });
831+
let location = self
832+
.get_caller_location(bx, mir::SourceInfo { span: func.span, ..source_info });
834833

835834
if let ReturnDest::IndirectOperand(tmp, _) = ret_dest {
836835
location.val.store(bx, tmp);
@@ -1019,16 +1018,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10191018
} else {
10201019
args.len()
10211020
};
1021+
let fn_span = func.span;
10221022
assert_eq!(
10231023
fn_abi.args.len(),
10241024
mir_args + 1,
10251025
"#[track_caller] fn's must have 1 more argument in their ABI than in their MIR: {instance:?} {fn_span:?} {fn_abi:?}",
10261026
);
10271027
let location =
1028-
self.get_caller_location(bx, mir::SourceInfo { span: fn_span, ..source_info });
1028+
self.get_caller_location(bx, mir::SourceInfo { span: func.span, ..source_info });
10291029
debug!(
1030-
"codegen_call_terminator({:?}): location={:?} (fn_span {:?})",
1031-
terminator, location, fn_span
1030+
"codegen_call_terminator({:?}): location={:?} (func.span {:?})",
1031+
terminator, location, func.span
10321032
);
10331033

10341034
let last_arg = fn_abi.args.last().unwrap();
@@ -1256,7 +1256,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12561256
target,
12571257
unwind,
12581258
call_source: _,
1259-
fn_span,
12601259
} => self.codegen_call_terminator(
12611260
helper,
12621261
bx,
@@ -1266,7 +1265,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12661265
destination,
12671266
target,
12681267
unwind,
1269-
fn_span,
12701268
mergeable_succ(),
12711269
),
12721270
mir::TerminatorKind::CoroutineDrop | mir::TerminatorKind::Yield { .. } => {

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_middle::ty::layout::{
1818
use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt, TypeFoldable, Variance};
1919
use rustc_mir_dataflow::storage::always_storage_live_locals;
2020
use rustc_session::Limit;
21-
use rustc_span::Span;
21+
use rustc_span::{source_map::Spanned, Span};
2222
use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout};
2323

2424
use super::{
@@ -620,8 +620,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
620620
block.terminator(),
621621
block.terminator().kind,
622622
);
623-
if let mir::TerminatorKind::Call { fn_span, .. } = block.terminator().kind {
624-
source_info.span = fn_span;
623+
if let mir::TerminatorKind::Call { func: Spanned { span, .. }, .. } =
624+
block.terminator().kind
625+
{
626+
source_info.span = span;
625627
}
626628
}
627629

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
111111
self.go_to_block(target_block);
112112
}
113113

114-
Call {
115-
ref func,
116-
ref args,
117-
destination,
118-
target,
119-
unwind,
120-
call_source: _,
121-
fn_span: _,
122-
} => {
114+
Call { ref func, ref args, destination, target, unwind, call_source: _ } => {
123115
let old_stack = self.frame_idx();
124116
let old_loc = self.frame().loc;
125-
let func = self.eval_operand(func, None)?;
117+
let func = self.eval_operand(&func.node, None)?;
126118
let args = self.eval_fn_call_arguments(args)?;
127119

128120
let fn_sig_binder = func.layout.ty.fn_sig(*self.tcx);

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,11 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
713713
self.super_terminator(terminator, location);
714714

715715
match &terminator.kind {
716-
TerminatorKind::Call { func, args, fn_span, call_source, .. } => {
716+
TerminatorKind::Call { func, args, call_source, .. } => {
717717
let ConstCx { tcx, body, param_env, .. } = *self.ccx;
718718
let caller = self.def_id();
719719

720-
let fn_ty = func.ty(body, tcx);
720+
let fn_ty = func.node.ty(body, tcx);
721721

722722
let (mut callee, mut fn_args) = match *fn_ty.kind() {
723723
ty::FnDef(def_id, fn_args) => (def_id, fn_args),
@@ -784,7 +784,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
784784
caller,
785785
callee,
786786
args: fn_args,
787-
span: *fn_span,
787+
span: func.span,
788788
call_source: *call_source,
789789
feature: Some(if tcx.features().const_trait_impl {
790790
sym::effects
@@ -831,7 +831,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
831831
caller,
832832
callee,
833833
args: fn_args,
834-
span: *fn_span,
834+
span: func.span,
835835
call_source: *call_source,
836836
feature: None,
837837
});

0 commit comments

Comments
 (0)