diff options
| author | Ralf Jung <post@ralfj.de> | 2021-11-29 22:02:17 -0500 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2021-12-20 22:37:14 +0100 |
| commit | fcc5fd6135c1c7b1c3933ce8df12f20799e2da13 (patch) | |
| tree | a5c60511a616ddfeeb7e381a04ea048c8a86e8ab /compiler/rustc_const_eval/src | |
| parent | 11fb22d83aafd3f3ba66d54ff5ecdbfe5069cb83 (diff) | |
| download | rust-fcc5fd6135c1c7b1c3933ce8df12f20799e2da13.tar.gz rust-fcc5fd6135c1c7b1c3933ce8df12f20799e2da13.zip | |
const_eval machine: use original instance for replaced MIR bodies
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/machine.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index d101c786c45..fef0e00e507 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -279,7 +279,17 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, if let Some(new_instance) = ecx.hook_special_const_fn(instance, args)? { // We call another const fn instead. - return Self::find_mir_or_eval_fn(ecx, new_instance, _abi, args, _ret, _unwind); + // However, we return the *original* instance to make backtraces work out + // (and we hope this does not confuse the FnAbi checks too much). + return Ok(Self::find_mir_or_eval_fn( + ecx, + new_instance, + _abi, + args, + _ret, + _unwind, + )? + .map(|(body, _instance)| (body, instance))); } } // This is a const fn. Call it. |
