]> git.proxmox.com Git - rustc.git/blob - src/test/codegen-units/item-collection/drop_in_place_intrinsic.rs
Update upstream source from tag 'upstream/1.42.0+dfsg1'
[rustc.git] / src / test / codegen-units / item-collection / drop_in_place_intrinsic.rs
1 // ignore-tidy-linelength
2 // compile-flags:-Zprint-mono-items=eager
3 // compile-flags:-Zinline-in-all-cgus
4
5 #![feature(start)]
6
7 //~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<drop_in_place_intrinsic::StructWithDtor[0]> @@ drop_in_place_intrinsic-cgu.0[Internal]
8 struct StructWithDtor(u32);
9
10 impl Drop for StructWithDtor {
11 //~ MONO_ITEM fn drop_in_place_intrinsic::{{impl}}[0]::drop[0]
12 fn drop(&mut self) {}
13 }
14
15 //~ MONO_ITEM fn drop_in_place_intrinsic::start[0]
16 #[start]
17 fn start(_: isize, _: *const *const u8) -> isize {
18
19 //~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]; 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_in_place_intrinsic::drop_slice_in_place[0]
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 core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]]> @@ drop_in_place_intrinsic-cgu.0[Internal]
34 ::std::ptr::drop_in_place(x as *const _ as *mut [StructWithDtor]);
35 }
36 }