]> git.proxmox.com Git - rustc.git/blob - tests/codegen/drop-in-place-noalias.rs
New upstream version 1.73.0+dfsg1
[rustc.git] / tests / codegen / drop-in-place-noalias.rs
1 // compile-flags: -O -C no-prepopulate-passes
2
3 // Tests that the compiler can apply `noalias` and other &mut attributes to `drop_in_place`.
4 // Note that non-Unpin types should not get `noalias`, matching &mut behavior.
5
6 #![crate_type="lib"]
7
8 use std::marker::PhantomPinned;
9
10 // CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}(ptr noalias noundef align 4 dereferenceable(12) %{{.+}})
11
12 // CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}(ptr noundef nonnull align 4 %{{.+}})
13
14 pub struct StructUnpin {
15 a: i32,
16 b: i32,
17 c: i32,
18 }
19
20 impl Drop for StructUnpin {
21 fn drop(&mut self) {}
22 }
23
24 pub struct StructNotUnpin {
25 a: i32,
26 b: i32,
27 c: i32,
28 p: PhantomPinned,
29 }
30
31 impl Drop for StructNotUnpin {
32 fn drop(&mut self) {}
33 }
34
35 pub unsafe fn main(x: StructUnpin, y: StructNotUnpin) {
36 drop(x);
37 drop(y);
38 }