add test for Drop terminator on non-drop type

This commit is contained in:
Ralf Jung 2024-04-18 10:23:22 +02:00
parent d261b53081
commit 5c352a4e75

View File

@ -0,0 +1,21 @@
#![feature(custom_mir, core_intrinsics, strict_provenance)]
use std::intrinsics::mir::*;
// The `Drop` terminator on a type with no drop glue should be a NOP.
#[custom_mir(dialect = "runtime", phase = "optimized")]
fn drop_in_place_with_terminator(ptr: *mut i32) {
mir! {
{
Drop(*ptr, ReturnTo(after_call), UnwindContinue())
}
after_call = {
Return()
}
}
}
pub fn main() {
drop_in_place_with_terminator(std::ptr::without_provenance_mut(0));
drop_in_place_with_terminator(std::ptr::without_provenance_mut(1));
}