1
- //@ compile-flags:-Clink-dead-code -Zinline-mir=no
1
+ //@ compile-flags:-Clink-dead-code -Zinline-mir=no -Zhuman-readable-cgu-names
2
2
3
3
#![ deny( dead_code) ]
4
4
#![ crate_type = "lib" ]
@@ -22,9 +22,8 @@ fn assigned_to_variable_but_not_executed() {
22
22
//~ MONO_ITEM fn assigned_to_variable_executed_indirectly @@ non_generic_closures-cgu.0[External]
23
23
fn assigned_to_variable_executed_indirectly ( ) {
24
24
//~ MONO_ITEM fn assigned_to_variable_executed_indirectly::{closure#0} @@ non_generic_closures-cgu.0[External]
25
- //~ MONO_ITEM fn <{closure@TEST_PATH:28:13: 28:21} as std::ops::FnOnce<(i32,)>>::call_once - shim @@ non_generic_closures-cgu.0[External]
26
- //~ MONO_ITEM fn <{closure@TEST_PATH:28:13: 28:21} as std::ops::FnOnce<(i32,)>>::call_once - shim(vtable) @@ non_generic_closures-cgu.0[External]
27
- //~ MONO_ITEM fn std::ptr::drop_in_place::<{closure@TEST_PATH:28:13: 28:21}> - shim(None) @@ non_generic_closures-cgu.0[External]
25
+ //~ MONO_ITEM fn <{closure@TEST_PATH:27:13: 27:21} as std::ops::FnOnce<(i32,)>>::call_once - shim @@ non_generic_closures-cgu.0[External]
26
+ //~ MONO_ITEM fn <{closure@TEST_PATH:27:13: 27:21} as std::ops::FnOnce<(i32,)>>::call_once - shim(vtable) @@ non_generic_closures-cgu.0[External]
28
27
let f = |a : i32 | {
29
28
let _ = a + 2 ;
30
29
} ;
@@ -40,13 +39,28 @@ fn assigned_to_variable_executed_directly() {
40
39
f ( 4 ) ;
41
40
}
42
41
42
+ // Make sure we generate mono items for stateful closures that need dropping
43
+ //~ MONO_ITEM fn with_drop @@ non_generic_closures-cgu.0[External]
44
+ fn with_drop ( v : PresentDrop ) {
45
+ //~ MONO_ITEM fn with_drop::{closure#0} @@ non_generic_closures-cgu.0[External]
46
+ //~ MONO_ITEM fn std::ptr::drop_in_place::<PresentDrop> - shim(Some(PresentDrop)) @@ non_generic_closures-cgu.0[Internal]
47
+ //~ MONO_ITEM fn std::ptr::drop_in_place::<{closure@TEST_PATH:49:14: 49:24}> - shim(Some({closure@TEST_PATH:49:14: 49:24})) @@ non_generic_closures-cgu.0[Internal]
48
+
49
+ let _f = |a : usize | {
50
+ let _ = a + 2 ;
51
+ //~ MONO_ITEM fn std::mem::drop::<PresentDrop> @@ non_generic_closures-cgu.0[External]
52
+ drop ( v) ;
53
+ } ;
54
+ }
55
+
43
56
//~ MONO_ITEM fn start @@ non_generic_closures-cgu.0[External]
44
57
#[ no_mangle]
45
58
pub fn start ( _: isize , _: * const * const u8 ) -> isize {
46
59
temporary ( ) ;
47
60
assigned_to_variable_but_not_executed ( ) ;
48
61
assigned_to_variable_executed_directly ( ) ;
49
62
assigned_to_variable_executed_indirectly ( ) ;
63
+ with_drop ( PresentDrop ) ;
50
64
51
65
0
52
66
}
@@ -55,3 +69,10 @@ pub fn start(_: isize, _: *const *const u8) -> isize {
55
69
fn run_closure ( f : & Fn ( i32 ) ) {
56
70
f ( 3 ) ;
57
71
}
72
+
73
+ struct PresentDrop ;
74
+
75
+ impl Drop for PresentDrop {
76
+ //~ MONO_ITEM fn <PresentDrop as std::ops::Drop>::drop @@ non_generic_closures-cgu.0[External]
77
+ fn drop ( & mut self ) { }
78
+ }
0 commit comments