From 5c352a4e7571d09a2cc5fe9c5bc86b02d62b49d8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 18 Apr 2024 10:23:22 +0200 Subject: add test for Drop terminator on non-drop type --- .../miri/tests/pass/drop_type_without_drop_glue.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/tools/miri/tests/pass/drop_type_without_drop_glue.rs diff --git a/src/tools/miri/tests/pass/drop_type_without_drop_glue.rs b/src/tools/miri/tests/pass/drop_type_without_drop_glue.rs new file mode 100644 index 00000000000..43ddc8a4d8b --- /dev/null +++ b/src/tools/miri/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)); +} -- cgit 1.4.1-3-g733a5