@@ -10,9 +10,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
1010use rustc_hir as hir;
1111use rustc_middle:: middle:: region;
1212use rustc_middle:: mir:: * ;
13- use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation } ;
14- use rustc_span:: symbol:: sym;
15- use rustc_target:: spec:: abi:: Abi ;
13+ use rustc_middle:: ty:: { CanonicalUserTypeAnnotation } ;
1614
1715use std:: slice;
1816
@@ -185,79 +183,41 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
185183 } ,
186184 )
187185 }
188- ExprKind :: Call { ty, fun, args, from_hir_call, fn_span } => {
189- let intrinsic = match * ty. kind ( ) {
190- ty:: FnDef ( def_id, _) => {
191- let f = ty. fn_sig ( this. hir . tcx ( ) ) ;
192- if f. abi ( ) == Abi :: RustIntrinsic || f. abi ( ) == Abi :: PlatformIntrinsic {
193- Some ( this. hir . tcx ( ) . item_name ( def_id) )
194- } else {
195- None
196- }
197- }
198- _ => None ,
199- } ;
186+ ExprKind :: Call { ty : _, fun, args, from_hir_call, fn_span } => {
200187 let fun = unpack ! ( block = this. as_local_operand( block, fun) ) ;
201- if let Some ( sym:: move_val_init) = intrinsic {
202- // `move_val_init` has "magic" semantics - the second argument is
203- // always evaluated "directly" into the first one.
204-
205- let mut args = args. into_iter ( ) ;
206- let ptr = args. next ( ) . expect ( "0 arguments to `move_val_init`" ) ;
207- let val = args. next ( ) . expect ( "1 argument to `move_val_init`" ) ;
208- assert ! ( args. next( ) . is_none( ) , ">2 arguments to `move_val_init`" ) ;
209-
210- let ptr = this. hir . mirror ( ptr) ;
211- let ptr_ty = ptr. ty ;
212- // Create an *internal* temp for the pointer, so that unsafety
213- // checking won't complain about the raw pointer assignment.
214- let ptr_temp = this
215- . local_decls
216- . push ( LocalDecl :: with_source_info ( ptr_ty, source_info) . internal ( ) ) ;
217- let ptr_temp = Place :: from ( ptr_temp) ;
218- // No need for a scope, ptr_temp doesn't need drop
219- let block = unpack ! ( this. into( ptr_temp, None , block, ptr) ) ;
220- // Maybe we should provide a scope here so that
221- // `move_val_init` wouldn't leak on panic even with an
222- // arbitrary `val` expression, but `schedule_drop`,
223- // borrowck and drop elaboration all prevent us from
224- // dropping `ptr_temp.deref()`.
225- this. into ( this. hir . tcx ( ) . mk_place_deref ( ptr_temp) , None , block, val)
226- } else {
227- let args: Vec < _ > = args
228- . into_iter ( )
229- . map ( |arg| unpack ! ( block = this. as_local_call_operand( block, arg) ) )
230- . collect ( ) ;
231-
232- let success = this. cfg . start_new_block ( ) ;
233-
234- this. record_operands_moved ( & args) ;
235-
236- debug ! ( "into_expr: fn_span={:?}" , fn_span) ;
237-
238- this. cfg . terminate (
239- block,
240- source_info,
241- TerminatorKind :: Call {
242- func : fun,
243- args,
244- cleanup : None ,
245- // FIXME(varkor): replace this with an uninhabitedness-based check.
246- // This requires getting access to the current module to call
247- // `tcx.is_ty_uninhabited_from`, which is currently tricky to do.
248- destination : if expr. ty . is_never ( ) {
249- None
250- } else {
251- Some ( ( destination, success) )
252- } ,
253- from_hir_call,
254- fn_span,
188+ let args: Vec < _ > = args
189+ . into_iter ( )
190+ . map ( |arg| unpack ! ( block = this. as_local_call_operand( block, arg) ) )
191+ . collect ( ) ;
192+
193+ let success = this. cfg . start_new_block ( ) ;
194+
195+ this. record_operands_moved ( & args) ;
196+
197+ debug ! ( "into_expr: fn_span={:?}" , fn_span) ;
198+
199+ this. cfg . terminate (
200+ block,
201+ source_info,
202+ TerminatorKind :: Call {
203+ func : fun,
204+ args,
205+ cleanup : None ,
206+ // FIXME(varkor): replace this with an uninhabitedness-based check.
207+ // This requires getting access to the current module to call
208+ // `tcx.is_ty_uninhabited_from`, which is currently tricky to do.
209+ destination : if expr. ty . is_never ( ) {
210+ None
211+ } else {
212+ Some ( ( destination, success) )
255213 } ,
256- ) ;
257- this. diverge_from ( block) ;
258- schedule_drop ( this) ;
259- success. unit ( )
260- }
214+ from_hir_call,
215+ fn_span,
216+ } ,
217+ ) ;
218+ this. diverge_from ( block) ;
219+ schedule_drop ( this) ;
220+ success. unit ( )
261221 }
262222 ExprKind :: Use { source } => this. into ( destination, scope, block, source) ,
263223 ExprKind :: Borrow { arg, borrow_kind } => {
0 commit comments