]> git.lizzy.rs Git - rust.git/blob - src/test/codegen-units/item-collection/drop_in_place_intrinsic.rs
Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3
[rust.git] / src / test / codegen-units / item-collection / drop_in_place_intrinsic.rs
1 //
2 // compile-flags:-Zprint-mono-items=eager
3 // compile-flags:-Zinline-in-all-cgus
4
5 #![feature(start)]
6
7 //~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDtor> - shim(Some(StructWithDtor)) @@ drop_in_place_intrinsic-cgu.0[Internal]
8 struct StructWithDtor(u32);
9
10 impl Drop for StructWithDtor {
11     //~ MONO_ITEM fn <StructWithDtor as std::ops::Drop>::drop
12     fn drop(&mut self) {}
13 }
14
15 //~ MONO_ITEM fn start
16 #[start]
17 fn start(_: isize, _: *const *const u8) -> isize {
18
19     //~ MONO_ITEM fn std::ptr::drop_in_place::<[StructWithDtor; 2]> - shim(Some([StructWithDtor; 2])) @@ drop_in_place_intrinsic-cgu.0[Internal]
20     let x = [StructWithDtor(0), StructWithDtor(1)];
21
22     drop_slice_in_place(&x);
23
24     0
25 }
26
27 //~ MONO_ITEM fn drop_slice_in_place
28 fn drop_slice_in_place(x: &[StructWithDtor]) {
29     unsafe {
30         // This is the interesting thing in this test case: Normally we would
31         // not have drop-glue for the unsized [StructWithDtor]. This has to be
32         // generated though when the drop_in_place() intrinsic is used.
33         //~ MONO_ITEM fn std::ptr::drop_in_place::<[StructWithDtor]> - shim(Some([StructWithDtor])) @@ drop_in_place_intrinsic-cgu.0[Internal]
34         ::std::ptr::drop_in_place(x as *const _ as *mut [StructWithDtor]);
35     }
36 }