2024-02-22 06:10:29 -06:00
|
|
|
//@ 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.
|
2022-10-26 17:12:19 -05:00
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
#![crate_type = "lib"]
|
2022-10-26 17:12:19 -05:00
|
|
|
|
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) %{{.+}})
|
2022-10-26 17:12:19 -05:00
|
|
|
|
2023-07-27 16:44:13 -05:00
|
|
|
// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}(ptr noundef nonnull align 4 %{{.+}})
|
2022-10-26 17:12:19 -05:00
|
|
|
|
2023-05-20 18:34:31 -05:00
|
|
|
pub struct StructUnpin {
|
2022-10-26 17:12:19 -05:00
|
|
|
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,
|
2022-10-26 17:12:19 -05:00
|
|
|
}
|
|
|
|
|
2023-05-20 18:34:31 -05:00
|
|
|
impl Drop for StructNotUnpin {
|
|
|
|
fn drop(&mut self) {}
|
2022-10-26 17:12:19 -05:00
|
|
|
}
|
|
|
|
|
2023-05-20 18:34:31 -05:00
|
|
|
pub unsafe fn main(x: StructUnpin, y: StructNotUnpin) {
|
|
|
|
drop(x);
|
|
|
|
drop(y);
|
2022-10-26 17:12:19 -05:00
|
|
|
}
|