@@ -58,92 +58,11 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
58
58
} ;
59
59
60
60
let arg_uninhabited = fx. mir . args_iter ( ) . any ( |arg| fx. layout_of ( fx. monomorphize ( & fx. mir . local_decls [ arg] . ty ) ) . abi . is_uninhabited ( ) ) ;
61
- let is_call_once_for_box = name. starts_with ( "_ZN83_$LT$alloc..boxed..Box$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$9call_once" ) ;
62
61
63
62
if arg_uninhabited {
64
63
fx. bcx . append_block_params_for_function_params ( fx. block_map [ START_BLOCK ] ) ;
65
64
fx. bcx . switch_to_block ( fx. block_map [ START_BLOCK ] ) ;
66
65
crate :: trap:: trap_unreachable ( & mut fx, "function has uninhabited argument" ) ;
67
- } else if is_call_once_for_box {
68
- // HACK implement `<Box<F> as FnOnce>::call_once` without `alloca`.
69
- tcx. sess . time ( "codegen prelude" , || crate :: abi:: codegen_fn_prelude ( & mut fx, start_block, false ) ) ;
70
- fx. bcx . switch_to_block ( fx. block_map [ START_BLOCK ] ) ;
71
- let bb_data = & fx. mir . basic_blocks ( ) [ START_BLOCK ] ;
72
- let destination = match & bb_data. terminator ( ) . kind {
73
- TerminatorKind :: Call {
74
- func,
75
- args,
76
- destination,
77
- cleanup : _,
78
- from_hir_call : _,
79
- } => {
80
- assert_eq ! ( args. len( ) , 2 ) ;
81
-
82
- let closure_arg = Local :: new ( 1 ) ;
83
- let closure_local = args[ 0 ] . place ( ) . unwrap ( ) . as_local ( ) . unwrap ( ) ;
84
- assert_eq ! ( fx. mir. local_decls[ closure_local] . ty, fx. mir. local_decls[ closure_arg] . ty. builtin_deref( true ) . unwrap( ) . ty) ;
85
- let closure_deref = fx. local_map [ & closure_arg] . place_deref ( & mut fx) ;
86
- fx. local_map . insert ( closure_local, closure_deref) ;
87
-
88
- let args_arg = Local :: new ( 2 ) ;
89
- let args_local = args[ 1 ] . place ( ) . unwrap ( ) . as_local ( ) . unwrap ( ) ;
90
- assert_eq ! ( fx. mir. local_decls[ args_local] . ty, fx. mir. local_decls[ args_arg] . ty) ;
91
- fx. local_map . insert ( args_local, fx. local_map [ & args_arg] ) ;
92
-
93
- fx. tcx . sess . time ( "codegen call" , || crate :: abi:: codegen_terminator_call (
94
- & mut fx,
95
- bb_data. terminator ( ) . source_info . span ,
96
- func,
97
- args,
98
- * destination,
99
- ) ) ;
100
- destination. map ( |( _ret_place, ret_block) | ret_block)
101
- }
102
- _ => unreachable ! ( ) ,
103
- } ;
104
-
105
- let destination = if let Some ( destination) = destination {
106
- fx. bcx . switch_to_block ( fx. block_map [ destination] ) ;
107
- let bb_data = & fx. mir . basic_blocks ( ) [ destination] ;
108
- match & bb_data. terminator ( ) . kind {
109
- TerminatorKind :: Call {
110
- func,
111
- args,
112
- destination,
113
- cleanup : _,
114
- from_hir_call : _,
115
- } => {
116
- match destination {
117
- Some ( ( ret_place, _ret_block) ) => {
118
- fx. local_map . insert ( ret_place. as_local ( ) . unwrap ( ) , CPlace :: no_place ( fx. layout_of ( fx. tcx . mk_unit ( ) ) ) ) ;
119
- }
120
- None => { }
121
- }
122
-
123
- assert_eq ! ( args. len( ) , 1 ) ;
124
- fx. tcx . sess . time ( "codegen call" , || crate :: abi:: codegen_terminator_call (
125
- & mut fx,
126
- bb_data. terminator ( ) . source_info . span ,
127
- func,
128
- args,
129
- * destination,
130
- ) ) ;
131
- destination. map ( |( _ret_place, ret_block) | ret_block)
132
- }
133
- _ => unreachable ! ( ) ,
134
- }
135
- } else {
136
- None
137
- } ;
138
-
139
- if let Some ( destination) = destination {
140
- fx. bcx . switch_to_block ( fx. block_map [ destination] ) ;
141
- let bb_data = & fx. mir . basic_blocks ( ) [ destination] ;
142
- match & bb_data. terminator ( ) . kind {
143
- TerminatorKind :: Return => crate :: abi:: codegen_return ( & mut fx) ,
144
- _ => unreachable ! ( ) ,
145
- }
146
- }
147
66
} else {
148
67
tcx. sess . time ( "codegen clif ir" , || {
149
68
tcx. sess . time ( "codegen prelude" , || crate :: abi:: codegen_fn_prelude ( & mut fx, start_block, true ) ) ;
0 commit comments