Skip to content

Commit e86636c

Browse files
committed
Auto merge of #128739 - matthiaskrgr:rollup-d7ecih7, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #125048 (PinCoerceUnsized trait into core) - #128273 (Improve `Ord` violation help) - #128406 (implement BufReader::peek) - #128539 (Forbid unused unsafe in vxworks-specific std modules) - #128687 (interpret: refactor function call handling to be better-abstracted) - #128692 (Add a triagebot mention for `library/Cargo.lock`) - #128710 (Don't ICE when getting an input file name's stem fails) - #128718 (Consider `cfg_attr` checked by `CheckAttrVisitor`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 60d1465 + 38c2e62 commit e86636c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1956
-1426
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
7373
cid.promoted.map_or_else(String::new, |p| format!("::{p:?}"))
7474
);
7575

76-
ecx.push_stack_frame(
76+
// This can't use `init_stack_frame` since `body` is not a function,
77+
// so computing its ABI would fail. It's also not worth it since there are no arguments to pass.
78+
ecx.push_stack_frame_raw(
7779
cid.instance,
7880
body,
7981
&ret.clone().into(),

compiler/rustc_const_eval/src/const_eval/machine.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ use crate::errors::{LongRunning, LongRunningWarn};
2424
use crate::fluent_generated as fluent;
2525
use crate::interpret::{
2626
self, compile_time_machine, err_ub, throw_exhaust, throw_inval, throw_ub_custom, throw_unsup,
27-
throw_unsup_format, AllocId, AllocRange, ConstAllocation, CtfeProvenance, FnArg, FnVal, Frame,
27+
throw_unsup_format, AllocId, AllocRange, ConstAllocation, CtfeProvenance, FnArg, Frame,
2828
GlobalAlloc, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, PointerArithmetic, Scalar,
29+
StackPopCleanup,
2930
};
3031

3132
/// When hitting this many interpreted terminators we emit a deny by default lint
@@ -306,17 +307,15 @@ impl<'tcx> CompileTimeInterpCx<'tcx> {
306307
let align = ImmTy::from_uint(target_align, args[1].layout).into();
307308
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty())?;
308309

309-
// We replace the entire function call with a "tail call".
310-
// Note that this happens before the frame of the original function
311-
// is pushed on the stack.
312-
self.eval_fn_call(
313-
FnVal::Instance(instance),
314-
(CallAbi::Rust, fn_abi),
310+
// Push the stack frame with our own adjusted arguments.
311+
self.init_stack_frame(
312+
instance,
313+
self.load_mir(instance.def, None)?,
314+
fn_abi,
315315
&[FnArg::Copy(addr), FnArg::Copy(align)],
316316
/* with_caller_location = */ false,
317317
dest,
318-
ret,
319-
mir::UnwindAction::Unreachable,
318+
StackPopCleanup::Goto { ret, unwind: mir::UnwindAction::Unreachable },
320319
)?;
321320
Ok(ControlFlow::Break(()))
322321
} else {

0 commit comments

Comments
 (0)