2023-05-23 00:20:45 +00:00
|
|
|
//@ compile-flags: -O -C no-prepopulate-passes
|
2023-05-20 23:34:31 +00: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.
|
2022-10-26 22:12:19 +00:00
|
|
|
|
2024-05-29 04:11:20 +00:00
|
|
|
#![crate_type = "lib"]
|
2022-10-26 22:12:19 +00:00
|
|
|
|
2023-05-20 23:34:31 +00:00
|
|
|
use std::marker::PhantomPinned;
|
|
|
|
|
2023-07-27 21:44:13 +00:00
|
|
|
// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}(ptr noalias noundef align 4 dereferenceable(12) %{{.+}})
|
2022-10-26 22:12:19 +00:00
|
|
|
|
2023-07-27 21:44:13 +00:00
|
|
|
// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}(ptr noundef nonnull align 4 %{{.+}})
|
2022-10-26 22:12:19 +00:00
|
|
|
|
2023-05-20 23:34:31 +00:00
|
|
|
pub struct StructUnpin {
|
2022-10-26 22:12:19 +00:00
|
|
|
a: i32,
|
|
|
|
b: i32,
|
|
|
|
c: i32,
|
|
|
|
}
|
|
|
|
|
2023-05-20 23:34:31 +00:00
|
|
|
impl Drop for StructUnpin {
|
|
|
|
fn drop(&mut self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct StructNotUnpin {
|
|
|
|
a: i32,
|
|
|
|
b: i32,
|
|
|
|
c: i32,
|
|
|
|
p: PhantomPinned,
|
2022-10-26 22:12:19 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 23:34:31 +00:00
|
|
|
impl Drop for StructNotUnpin {
|
|
|
|
fn drop(&mut self) {}
|
2022-10-26 22:12:19 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 23:34:31 +00:00
|
|
|
pub unsafe fn main(x: StructUnpin, y: StructNotUnpin) {
|
|
|
|
drop(x);
|
|
|
|
drop(y);
|
2022-10-26 22:12:19 +00:00
|
|
|
}
|