@@ -463,8 +463,28 @@ impl FunctionCx<'a, 'll, 'tcx> {
463
463
return ;
464
464
}
465
465
466
+ let extra_args = & args[ sig. inputs ( ) . len ( ) ..] ;
467
+ let extra_args = extra_args. iter ( ) . map ( |op_arg| {
468
+ let op_ty = op_arg. ty ( self . mir , bx. tcx ( ) ) ;
469
+ self . monomorphize ( & op_ty)
470
+ } ) . collect :: < Vec < _ > > ( ) ;
471
+
472
+ let fn_ty = match def {
473
+ Some ( ty:: InstanceDef :: Virtual ( ..) ) => {
474
+ FnType :: new_vtable ( bx. cx , sig, & extra_args)
475
+ }
476
+ Some ( ty:: InstanceDef :: DropGlue ( _, None ) ) => {
477
+ // empty drop glue - a nop.
478
+ let & ( _, target) = destination. as_ref ( ) . unwrap ( ) ;
479
+ funclet_br ( self , bx, target) ;
480
+ return ;
481
+ }
482
+ _ => FnType :: new ( bx. cx , sig, & extra_args)
483
+ } ;
484
+
485
+ // emit a panic instead of instantiating an uninhabited type
466
486
if ( intrinsic == Some ( "init" ) || intrinsic == Some ( "uninit" ) ) &&
467
- bx . cx . layout_of ( sig . output ( ) ) . abi . is_uninhabited ( )
487
+ fn_ty . ret . layout . abi . is_uninhabited ( )
468
488
{
469
489
let loc = bx. sess ( ) . codemap ( ) . lookup_char_pos ( span. lo ( ) ) ;
470
490
let filename = Symbol :: intern ( & loc. file . name . to_string ( ) ) . as_str ( ) ;
@@ -510,25 +530,6 @@ impl FunctionCx<'a, 'll, 'tcx> {
510
530
return ;
511
531
}
512
532
513
- let extra_args = & args[ sig. inputs ( ) . len ( ) ..] ;
514
- let extra_args = extra_args. iter ( ) . map ( |op_arg| {
515
- let op_ty = op_arg. ty ( self . mir , bx. tcx ( ) ) ;
516
- self . monomorphize ( & op_ty)
517
- } ) . collect :: < Vec < _ > > ( ) ;
518
-
519
- let fn_ty = match def {
520
- Some ( ty:: InstanceDef :: Virtual ( ..) ) => {
521
- FnType :: new_vtable ( bx. cx , sig, & extra_args)
522
- }
523
- Some ( ty:: InstanceDef :: DropGlue ( _, None ) ) => {
524
- // empty drop glue - a nop.
525
- let & ( _, target) = destination. as_ref ( ) . unwrap ( ) ;
526
- funclet_br ( self , bx, target) ;
527
- return ;
528
- }
529
- _ => FnType :: new ( bx. cx , sig, & extra_args)
530
- } ;
531
-
532
533
// The arguments we'll be passing. Plus one to account for outptr, if used.
533
534
let arg_count = fn_ty. args . len ( ) + fn_ty. ret . is_indirect ( ) as usize ;
534
535
let mut llargs = Vec :: with_capacity ( arg_count) ;
0 commit comments