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.
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.
11 // ignore-tidy-linelength
12 // compile-flags:-Zprint-trans-items=eager
13 // compile-flags:-Zinline-in-all-cgus
18 struct StructWithDrop
<T1
, T2
> {
23 impl<T1
, T2
> Drop
for StructWithDrop
<T1
, T2
> {
27 struct StructNoDrop
<T1
, T2
> {
32 enum EnumWithDrop
<T1
, T2
> {
37 impl<T1
, T2
> Drop
for EnumWithDrop
<T1
, T2
> {
41 enum EnumNoDrop
<T1
, T2
> {
47 struct NonGenericNoDrop(i32);
49 struct NonGenericWithDrop(i32);
50 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::NonGenericWithDrop[0]> @@ generic_drop_glue0[Internal]
52 impl Drop
for NonGenericWithDrop
{
53 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[2]::drop[0]
57 //~ TRANS_ITEM fn generic_drop_glue::start[0]
59 fn start(_
: isize, _
: *const *const u8) -> isize {
60 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<i8, char>> @@ generic_drop_glue0[Internal]
61 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<i8, char>
62 let _
= StructWithDrop { x: 0i8, y: 'a' }
.x
;
64 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>> @@ generic_drop_glue0[Internal]
65 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>
66 let _
= StructWithDrop { x: "&str", y: NonGenericNoDrop(0) }
.y
;
68 // Should produce no drop glue
69 let _
= StructNoDrop { x: 'a', y: 0u32 }
.x
;
71 // This is supposed to generate drop-glue because it contains a field that
72 // needs to be dropped.
73 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructNoDrop[0]<generic_drop_glue::NonGenericWithDrop[0], f64>> @@ generic_drop_glue0[Internal]
74 let _
= StructNoDrop { x: NonGenericWithDrop(0), y: 0f64 }
.y
;
76 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<i32, i64>> @@ generic_drop_glue0[Internal]
77 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<i32, i64>
78 let _
= match EnumWithDrop
::A
::<i32, i64>(0) {
79 EnumWithDrop
::A(x
) => x
,
80 EnumWithDrop
::B(x
) => x
as i32
83 //~TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<f64, f32>> @@ generic_drop_glue0[Internal]
84 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<f64, f32>
85 let _
= match EnumWithDrop
::B
::<f64, f32>(1.0) {
86 EnumWithDrop
::A(x
) => x
,
87 EnumWithDrop
::B(x
) => x
as f64
90 let _
= match EnumNoDrop
::A
::<i32, i64>(0) {
91 EnumNoDrop
::A(x
) => x
,
92 EnumNoDrop
::B(x
) => x
as i32
95 let _
= match EnumNoDrop
::B
::<f64, f32>(1.0) {
96 EnumNoDrop
::A(x
) => x
,
97 EnumNoDrop
::B(x
) => x
as f64