Skip to content

Commit

Permalink
Auto merge of rust-lang#3483 - RalfJung:drop, r=RalfJung
Browse files Browse the repository at this point in the history
add test for Drop terminator on non-drop type

Fixes rust-lang/miri#2737
  • Loading branch information
bors committed Apr 18, 2024
2 parents d261b53 + 5c352a4 commit 0f44382
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/tools/miri/tests/pass/drop_type_without_drop_glue.rs
Original file line number Diff line number Diff line change
@@ -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));
}

0 comments on commit 0f44382

Please sign in to comment.