Skip to content

Commit 8e98f40

Browse files
authored
Rollup merge of #137505 - tgross35:builtins-cannot-call-error, r=compiler-errors
Add a span to `CompilerBuiltinsCannotCall` Currently, this error emit a diagnostic with no context like: error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt` With this change, it at least usually points to the problematic function: error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt` --> src/../libm/src/math/support/hex_float.rs:270:5 | 270 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
2 parents bd63354 + 63a3ab4 commit 8e98f40

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: src/abi/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,13 @@ pub(crate) fn codegen_terminator_call<'tcx>(
402402

403403
if is_call_from_compiler_builtins_to_upstream_monomorphization(fx.tcx, instance) {
404404
if target.is_some() {
405-
let caller = with_no_trimmed_paths!(fx.tcx.def_path_str(fx.instance.def_id()));
406-
let callee = with_no_trimmed_paths!(fx.tcx.def_path_str(def_id));
407-
fx.tcx.dcx().emit_err(CompilerBuiltinsCannotCall { caller, callee });
405+
let caller_def = fx.instance.def_id();
406+
let e = CompilerBuiltinsCannotCall {
407+
span: fx.tcx.def_span(caller_def),
408+
caller: with_no_trimmed_paths!(fx.tcx.def_path_str(caller_def)),
409+
callee: with_no_trimmed_paths!(fx.tcx.def_path_str(def_id)),
410+
};
411+
fx.tcx.dcx().emit_err(e);
408412
} else {
409413
fx.bcx.ins().trap(TrapCode::user(2).unwrap());
410414
return;

0 commit comments

Comments
 (0)