Skip to content

Commit 55f4b04

Browse files
committed
Always use fn_span in codegen_call_terminator
1 parent bebbf1b commit 55f4b04

File tree

1 file changed

+10
-14
lines changed
  • compiler/rustc_codegen_ssa/src/mir

1 file changed

+10
-14
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
903903
fn_span: Span,
904904
mergeable_succ: bool,
905905
) -> MergingSucc {
906-
let source_info = terminator.source_info;
907-
let span = source_info.span;
906+
let source_info = mir::SourceInfo { span: fn_span, ..terminator.source_info };
908907

909908
// Create the callee. This is a fn ptr or zero-sized and hence a kind of scalar.
910909
let callee = self.codegen_operand(bx, func);
@@ -968,10 +967,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
968967

969968
if matches!(intrinsic, ty::IntrinsicDef { name: sym::caller_location, .. })
970969
{
971-
let location = self.get_caller_location(
972-
bx,
973-
mir::SourceInfo { span: fn_span, ..source_info },
974-
);
970+
let location = self.get_caller_location(bx, source_info);
975971

976972
assert_eq!(llargs, []);
977973
if let ReturnDest::IndirectOperand(tmp, _) = ret_dest {
@@ -981,8 +977,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
981977
return helper.funclet_br(self, bx, target.unwrap(), mergeable_succ);
982978
}
983979

984-
match Self::codegen_intrinsic_call(bx, instance, fn_abi, &args, dest, span)
985-
{
980+
match Self::codegen_intrinsic_call(
981+
bx, instance, fn_abi, &args, dest, fn_span,
982+
) {
986983
Ok(()) => {
987984
if let ReturnDest::IndirectOperand(dst, _) = ret_dest {
988985
self.store_return(bx, ret_dest, &fn_abi.ret, dst.val.llval);
@@ -998,7 +995,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
998995
Err(instance) => {
999996
if intrinsic.must_be_overridden {
1000997
span_bug!(
1001-
span,
998+
fn_span,
1002999
"intrinsic {} must be overridden by codegen backend, but isn't",
10031000
intrinsic.name,
10041001
);
@@ -1110,7 +1107,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11101107
// Make sure that we've actually unwrapped the rcvr down
11111108
// to a pointer or ref to `dyn* Trait`.
11121109
if !op.layout.ty.builtin_deref(true).unwrap().is_dyn_star() {
1113-
span_bug!(span, "can't codegen a virtual call on {:#?}", op);
1110+
span_bug!(fn_span, "can't codegen a virtual call on {:#?}", op);
11141111
}
11151112
let place = op.deref(bx.cx());
11161113
let data_place = place.project_field(bx, 0);
@@ -1126,7 +1123,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11261123
continue;
11271124
}
11281125
_ => {
1129-
span_bug!(span, "can't codegen a virtual call on {:#?}", op);
1126+
span_bug!(fn_span, "can't codegen a virtual call on {:#?}", op);
11301127
}
11311128
}
11321129
}
@@ -1169,8 +1166,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11691166
mir_args + 1,
11701167
"#[track_caller] fn's must have 1 more argument in their ABI than in their MIR: {instance:?} {fn_span:?} {fn_abi:?}",
11711168
);
1172-
let location =
1173-
self.get_caller_location(bx, mir::SourceInfo { span: fn_span, ..source_info });
1169+
let location = self.get_caller_location(bx, source_info);
11741170
debug!(
11751171
"codegen_call_terminator({:?}): location={:?} (fn_span {:?})",
11761172
terminator, location, fn_span
@@ -1183,7 +1179,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11831179
let fn_ptr = match (instance, llfn) {
11841180
(Some(instance), None) => bx.get_fn_addr(instance),
11851181
(_, Some(llfn)) => llfn,
1186-
_ => span_bug!(span, "no instance or llfn for call"),
1182+
_ => span_bug!(fn_span, "no instance or llfn for call"),
11871183
};
11881184
helper.do_call(
11891185
self,

0 commit comments

Comments
 (0)