rust/tests/codegen/drop-in-place-noalias.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
919 B
Rust
Raw Normal View History

//@ compile-flags: -O -C no-prepopulate-passes
2023-05-20 18:34:31 -05:00
// Tests that the compiler can apply `noalias` and other &mut attributes to `drop_in_place`.
// Note that non-Unpin types should not get `noalias`, matching &mut behavior.
#![crate_type = "lib"]
2023-05-20 18:34:31 -05:00
use std::marker::PhantomPinned;
2023-07-27 16:44:13 -05:00
// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}(ptr noalias noundef align 4 dereferenceable(12) %{{.+}})
2023-07-27 16:44:13 -05:00
// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}(ptr noundef nonnull align 4 %{{.+}})
2023-05-20 18:34:31 -05:00
pub struct StructUnpin {
a: i32,
b: i32,
c: i32,
}
2023-05-20 18:34:31 -05:00
impl Drop for StructUnpin {
fn drop(&mut self) {}
}
pub struct StructNotUnpin {
a: i32,
b: i32,
c: i32,
p: PhantomPinned,
}
2023-05-20 18:34:31 -05:00
impl Drop for StructNotUnpin {
fn drop(&mut self) {}
}
2023-05-20 18:34:31 -05:00
pub unsafe fn main(x: StructUnpin, y: StructNotUnpin) {
drop(x);
drop(y);
}