]>
Commit | Line | Data |
---|---|---|
7453a54e | 1 | // ignore-tidy-linelength |
94b46f34 | 2 | // compile-flags:-Zprint-mono-items=eager |
ea8adc8c | 3 | // compile-flags:-Zinline-in-all-cgus |
7453a54e SL |
4 | |
5 | #![deny(dead_code)] | |
ff7c6d11 | 6 | #![feature(start)] |
7453a54e SL |
7 | |
8 | struct StructWithDrop<T1, T2> { | |
9 | x: T1, | |
10 | y: T2, | |
11 | } | |
12 | ||
13 | impl<T1, T2> Drop for StructWithDrop<T1, T2> { | |
14 | fn drop(&mut self) {} | |
15 | } | |
16 | ||
17 | struct StructNoDrop<T1, T2> { | |
18 | x: T1, | |
19 | y: T2, | |
20 | } | |
21 | ||
22 | enum EnumWithDrop<T1, T2> { | |
23 | A(T1), | |
24 | B(T2) | |
25 | } | |
26 | ||
27 | impl<T1, T2> Drop for EnumWithDrop<T1, T2> { | |
28 | fn drop(&mut self) {} | |
29 | } | |
30 | ||
31 | enum EnumNoDrop<T1, T2> { | |
32 | A(T1), | |
33 | B(T2) | |
34 | } | |
35 | ||
36 | ||
37 | struct NonGenericNoDrop(i32); | |
38 | ||
39 | struct NonGenericWithDrop(i32); | |
1b1a35ee | 40 | //~ MONO_ITEM fn std::intrinsics::drop_in_place::<NonGenericWithDrop> - shim(Some(NonGenericWithDrop)) @@ generic_drop_glue-cgu.0[Internal] |
7453a54e SL |
41 | |
42 | impl Drop for NonGenericWithDrop { | |
1b1a35ee | 43 | //~ MONO_ITEM fn <NonGenericWithDrop as std::ops::Drop>::drop |
7453a54e | 44 | fn drop(&mut self) {} |
7453a54e SL |
45 | } |
46 | ||
1b1a35ee | 47 | //~ MONO_ITEM fn start |
ff7c6d11 XL |
48 | #[start] |
49 | fn start(_: isize, _: *const *const u8) -> isize { | |
1b1a35ee XL |
50 | //~ MONO_ITEM fn std::intrinsics::drop_in_place::<StructWithDrop<i8, char>> - shim(Some(StructWithDrop<i8, char>)) @@ generic_drop_glue-cgu.0[Internal] |
51 | //~ MONO_ITEM fn <StructWithDrop<i8, char> as std::ops::Drop>::drop | |
7453a54e SL |
52 | let _ = StructWithDrop { x: 0i8, y: 'a' }.x; |
53 | ||
1b1a35ee XL |
54 | //~ MONO_ITEM fn std::intrinsics::drop_in_place::<StructWithDrop<&str, NonGenericNoDrop>> - shim(Some(StructWithDrop<&str, NonGenericNoDrop>)) @@ generic_drop_glue-cgu.0[Internal] |
55 | //~ MONO_ITEM fn <StructWithDrop<&str, NonGenericNoDrop> as std::ops::Drop>::drop | |
7453a54e SL |
56 | let _ = StructWithDrop { x: "&str", y: NonGenericNoDrop(0) }.y; |
57 | ||
58 | // Should produce no drop glue | |
59 | let _ = StructNoDrop { x: 'a', y: 0u32 }.x; | |
60 | ||
61 | // This is supposed to generate drop-glue because it contains a field that | |
62 | // needs to be dropped. | |
1b1a35ee | 63 | //~ MONO_ITEM fn std::intrinsics::drop_in_place::<StructNoDrop<NonGenericWithDrop, f64>> - shim(Some(StructNoDrop<NonGenericWithDrop, f64>)) @@ generic_drop_glue-cgu.0[Internal] |
7453a54e SL |
64 | let _ = StructNoDrop { x: NonGenericWithDrop(0), y: 0f64 }.y; |
65 | ||
1b1a35ee XL |
66 | //~ MONO_ITEM fn std::intrinsics::drop_in_place::<EnumWithDrop<i32, i64>> - shim(Some(EnumWithDrop<i32, i64>)) @@ generic_drop_glue-cgu.0[Internal] |
67 | //~ MONO_ITEM fn <EnumWithDrop<i32, i64> as std::ops::Drop>::drop | |
7453a54e SL |
68 | let _ = match EnumWithDrop::A::<i32, i64>(0) { |
69 | EnumWithDrop::A(x) => x, | |
70 | EnumWithDrop::B(x) => x as i32 | |
71 | }; | |
72 | ||
1b1a35ee XL |
73 | //~ MONO_ITEM fn std::intrinsics::drop_in_place::<EnumWithDrop<f64, f32>> - shim(Some(EnumWithDrop<f64, f32>)) @@ generic_drop_glue-cgu.0[Internal] |
74 | //~ MONO_ITEM fn <EnumWithDrop<f64, f32> as std::ops::Drop>::drop | |
7453a54e SL |
75 | let _ = match EnumWithDrop::B::<f64, f32>(1.0) { |
76 | EnumWithDrop::A(x) => x, | |
77 | EnumWithDrop::B(x) => x as f64 | |
78 | }; | |
79 | ||
80 | let _ = match EnumNoDrop::A::<i32, i64>(0) { | |
81 | EnumNoDrop::A(x) => x, | |
82 | EnumNoDrop::B(x) => x as i32 | |
83 | }; | |
84 | ||
85 | let _ = match EnumNoDrop::B::<f64, f32>(1.0) { | |
86 | EnumNoDrop::A(x) => x, | |
87 | EnumNoDrop::B(x) => x as f64 | |
88 | }; | |
ff7c6d11 XL |
89 | |
90 | 0 | |
7453a54e | 91 | } |