Skip to content

Commit fcc5fd6

Browse files
committed
const_eval machine: use original instance for replaced MIR bodies
1 parent 11fb22d commit fcc5fd6

File tree

1 file changed

+11
-1
lines changed
  • compiler/rustc_const_eval/src/const_eval

1 file changed

+11
-1
lines changed

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,17 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
279279

280280
if let Some(new_instance) = ecx.hook_special_const_fn(instance, args)? {
281281
// We call another const fn instead.
282-
return Self::find_mir_or_eval_fn(ecx, new_instance, _abi, args, _ret, _unwind);
282+
// However, we return the *original* instance to make backtraces work out
283+
// (and we hope this does not confuse the FnAbi checks too much).
284+
return Ok(Self::find_mir_or_eval_fn(
285+
ecx,
286+
new_instance,
287+
_abi,
288+
args,
289+
_ret,
290+
_unwind,
291+
)?
292+
.map(|(body, _instance)| (body, instance)));
283293
}
284294
}
285295
// This is a const fn. Call it.

0 commit comments

Comments
 (0)