]> git.proxmox.com Git - rustc.git/blob - src/test/codegen-units/item-collection/drop_in_place_intrinsic.rs
New upstream version 1.24.1+dfsg1
[rustc.git] / src / test / codegen-units / item-collection / drop_in_place_intrinsic.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-tidy-linelength
12 // compile-flags:-Zprint-trans-items=eager
13 // compile-flags:-Zinline-in-all-cgus
14
15 #![feature(start)]
16
17 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<drop_in_place_intrinsic::StructWithDtor[0]> @@ drop_in_place_intrinsic0[Internal]
18 struct StructWithDtor(u32);
19
20 impl Drop for StructWithDtor {
21 //~ TRANS_ITEM fn drop_in_place_intrinsic::{{impl}}[0]::drop[0]
22 fn drop(&mut self) {}
23 }
24
25 //~ TRANS_ITEM fn drop_in_place_intrinsic::start[0]
26 #[start]
27 fn start(_: isize, _: *const *const u8) -> isize {
28
29 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]; 2]> @@ drop_in_place_intrinsic0[Internal]
30 let x = [StructWithDtor(0), StructWithDtor(1)];
31
32 drop_slice_in_place(&x);
33
34 0
35 }
36
37 //~ TRANS_ITEM fn drop_in_place_intrinsic::drop_slice_in_place[0]
38 fn drop_slice_in_place(x: &[StructWithDtor]) {
39 unsafe {
40 // This is the interesting thing in this test case: Normally we would
41 // not have drop-glue for the unsized [StructWithDtor]. This has to be
42 // generated though when the drop_in_place() intrinsic is used.
43 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<[drop_in_place_intrinsic::StructWithDtor[0]]> @@ drop_in_place_intrinsic0[Internal]
44 ::std::ptr::drop_in_place(x as *const _ as *mut [StructWithDtor]);
45 }
46 }