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
16 struct StructWithDrop
<T1
, T2
> {
21 impl<T1
, T2
> Drop
for StructWithDrop
<T1
, T2
> {
25 struct StructNoDrop
<T1
, T2
> {
30 enum EnumWithDrop
<T1
, T2
> {
35 impl<T1
, T2
> Drop
for EnumWithDrop
<T1
, T2
> {
39 enum EnumNoDrop
<T1
, T2
> {
45 struct NonGenericNoDrop(i32);
47 struct NonGenericWithDrop(i32);
48 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::NonGenericWithDrop[0]> @@ generic_drop_glue.cgu-0[Internal]
50 impl Drop
for NonGenericWithDrop
{
51 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[2]::drop[0]
55 //~ TRANS_ITEM fn generic_drop_glue::main[0]
57 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<i8, char>> @@ generic_drop_glue.cgu-0[Internal]
58 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<i8, char>
59 let _
= StructWithDrop { x: 0i8, y: 'a' }
.x
;
61 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructWithDrop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>> @@ generic_drop_glue.cgu-0[Internal]
62 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[0]::drop[0]<&str, generic_drop_glue::NonGenericNoDrop[0]>
63 let _
= StructWithDrop { x: "&str", y: NonGenericNoDrop(0) }
.y
;
65 // Should produce no drop glue
66 let _
= StructNoDrop { x: 'a', y: 0u32 }
.x
;
68 // This is supposed to generate drop-glue because it contains a field that
69 // needs to be dropped.
70 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::StructNoDrop[0]<generic_drop_glue::NonGenericWithDrop[0], f64>> @@ generic_drop_glue.cgu-0[Internal]
71 let _
= StructNoDrop { x: NonGenericWithDrop(0), y: 0f64 }
.y
;
73 //~ TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<i32, i64>> @@ generic_drop_glue.cgu-0[Internal]
74 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<i32, i64>
75 let _
= match EnumWithDrop
::A
::<i32, i64>(0) {
76 EnumWithDrop
::A(x
) => x
,
77 EnumWithDrop
::B(x
) => x
as i32
80 //~TRANS_ITEM fn core::ptr[0]::drop_in_place[0]<generic_drop_glue::EnumWithDrop[0]<f64, f32>> @@ generic_drop_glue.cgu-0[Internal]
81 //~ TRANS_ITEM fn generic_drop_glue::{{impl}}[1]::drop[0]<f64, f32>
82 let _
= match EnumWithDrop
::B
::<f64, f32>(1.0) {
83 EnumWithDrop
::A(x
) => x
,
84 EnumWithDrop
::B(x
) => x
as f64
87 let _
= match EnumNoDrop
::A
::<i32, i64>(0) {
88 EnumNoDrop
::A(x
) => x
,
89 EnumNoDrop
::B(x
) => x
as i32
92 let _
= match EnumNoDrop
::B
::<f64, f32>(1.0) {
93 EnumNoDrop
::A(x
) => x
,
94 EnumNoDrop
::B(x
) => x
as f64