rust-lang/rust · critical
Non terminating drop_in_place_real???
Error message
Non terminating drop_in_place_real???
What it means
This fires in Cranelift codegen's `codegen_terminator_call` when handling `InstanceKind::Shim(ShimKind::DropGlue(_, None))` — empty drop glue that is a no-op. The code does `target.expect("Non terminating drop_in_place_real???")` where `target` is the `Option<BasicBlock>` continuation for the MIR `Call` terminator. Empty drop glue should always return to a target block. If `target` is `None` (a non-returning/diverging call), the codegen panics because a no-op drop has nowhere to jump.
Source
Thrown at compiler/rustc_codegen_cranelift/src/abi/mod.rs:485
Err(instance) => Some(instance),
}
}
InstanceKind::LlvmIntrinsic(_) => {
crate::intrinsics::codegen_llvm_intrinsic_call(
fx,
fx.tcx.symbol_name(instance).name,
args,
ret_place,
target,
source_info.span,
);
return;
}
// We don't need AsyncDropGlueCtorShim here because it is not `noop func`,
// it is `func returning noop future`
InstanceKind::Shim(ShimKind::DropGlue(_, None)) => {
// empty drop glue - a nop.
let dest = target.expect("Non terminating drop_in_place_real???");
let ret_block = fx.get_block(dest);
fx.bcx.ins().jump(ret_block, &[]);
return;
}
_ => Some(instance),
}
} else {
None
};
let extra_args = &args[fn_sig.inputs().skip_binder().len()..];
let extra_args = fx.tcx.mk_type_list_from_iter(
extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.node.ty(fx.mir, fx.tcx))),
);
let fn_abi = if let Some(instance) = instance {
FullyMonomorphizedLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
} else {
FullyMonomorphizedLayoutCx(fx.tcx).fn_abi_of_fn_ptr(fn_sig, extra_args)View on GitHub (pinned to 7088e4b63a)
Solutions
- Report as an ICE — this is a compiler bug in MIR construction or a pass, not user code.
- Try compiling with `-Zmir-opt-level=0` to disable MIR optimizations that may corrupt the call target.
- Try the LLVM backend (`-Zcodegen-backend=llvm`) to determine if the issue is cg_clif-specific or a broader MIR problem.
- Minimize the reproduction and file a bug identifying the drop-glue call with `target: None`.
- If contributing to cg_clif, the code at `abi/mod.rs:485` could emit a trap instead of panicking when `target` is `None` for empty drop glue.
Example fix
# before (MIR optimization may strip the target for a no-op drop call) cargo build # after (disable MIR optimizations to avoid the corrupt call target) RUSTFLAGS='-Zmir-opt-level=0' cargo build
Defensive patterns
Strategy: fallback
Validate before calling
// No user-level validation for MIR correctness. // Fallback: disable MIR optimizations that may corrupt the call target. // In Cargo.toml or .cargo/config.toml: // [build] // rustflags = ["-Zmir-opt-level=0"]
Prevention
- Disable MIR optimizations (-Zmir-opt-level=0) if you encounter drop-related ICEs.
- Report the MIR body that produces a Drop call with target: None.
- Use the LLVM backend as a fallback for drop-heavy code.
- Track known cg_clif ICEs on the issue tracker.
When it happens
Trigger: Codegen of a MIR `Call` terminator targeting empty drop glue (a type whose `Drop` impl is trivially empty) where the call has no return target (`target: None`). This means the MIR indicates a diverging call to a function that is actually a no-op, which is contradictory.
Common situations: Compiling code that drops a type with no custom Drop logic in a diverging context, or where MIR optimization passes transform a call in a way that drops its return target. Usually indicates a bug in MIR construction or in a MIR optimization pass that dropped the `target` field for a call that should continue.
Related errors
- expected monomorphic const in codegen
- expected pointee to have a layout
- erroneous constant missed by mono item collection
- expected monomorphic const in codegen
- not implemented
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/aced6ae734ecd4da.
Report an issue: GitHub.