From 59fdf8ac7228478089ac6e8df2208adc5a61165c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 18 Apr 2024 10:23:22 +0200 Subject: [PATCH] add test for Drop terminator on non-drop type --- tests/pass/drop_type_without_drop_glue.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/pass/drop_type_without_drop_glue.rs diff --git a/tests/pass/drop_type_without_drop_glue.rs b/tests/pass/drop_type_without_drop_glue.rs new file mode 100644 index 0000000000..43ddc8a4d8 --- /dev/null +++ b/tests/pass/drop_type_without_drop_glue.rs @@ -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)); +}