Skip to content

Commit

Permalink
add test for Drop terminator on non-drop type
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Apr 18, 2024
1 parent da8c5dd commit 59fdf8a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 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 59fdf8a

Please sign in to comment.