@@ -463,8 +463,28 @@ impl FunctionCx<'a, 'll, 'tcx> {
463463 return ;
464464 }
465465
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
466486 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 ( )
468488 {
469489 let loc = bx. sess ( ) . codemap ( ) . lookup_char_pos ( span. lo ( ) ) ;
470490 let filename = Symbol :: intern ( & loc. file . name . to_string ( ) ) . as_str ( ) ;
@@ -510,25 +530,6 @@ impl FunctionCx<'a, 'll, 'tcx> {
510530 return ;
511531 }
512532
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-
532533 // The arguments we'll be passing. Plus one to account for outptr, if used.
533534 let arg_count = fn_ty. args . len ( ) + fn_ty. ret . is_indirect ( ) as usize ;
534535 let mut llargs = Vec :: with_capacity ( arg_count) ;
0 commit comments