mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
const_eval machine: use original instance for replaced MIR bodies
This commit is contained in:
parent
11fb22d83a
commit
fcc5fd6135
@ -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)? {
|
if let Some(new_instance) = ecx.hook_special_const_fn(instance, args)? {
|
||||||
// We call another const fn instead.
|
// 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.
|
// This is a const fn. Call it.
|
||||||
|
Loading…
Reference in New Issue
Block a user