@@ -4,9 +4,7 @@ use rustc_abi::{BackendRepr, ExternAbi, HasDataLayout, Reg, WrappingRange};
44use rustc_ast as ast;
55use rustc_ast:: { InlineAsmOptions , InlineAsmTemplatePiece } ;
66use rustc_hir:: lang_items:: LangItem ;
7- use rustc_middle:: mir:: {
8- self , AssertKind , BasicBlock , InlineAsmMacro , SwitchTargets , UnwindTerminateReason ,
9- } ;
7+ use rustc_middle:: mir:: { self , AssertKind , InlineAsmMacro , SwitchTargets , UnwindTerminateReason } ;
108use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf , ValidityRequirement } ;
119use rustc_middle:: ty:: print:: { with_no_trimmed_paths, with_no_visible_paths} ;
1210use rustc_middle:: ty:: { self , Instance , Ty } ;
@@ -919,7 +917,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
919917 & fn_abi. ret ,
920918 & mut llargs,
921919 Some ( intrinsic) ,
922- target,
923920 ) ;
924921 let dest = match ret_dest {
925922 _ if fn_abi. ret . is_indirect ( ) => llargs[ 0 ] ,
@@ -975,19 +972,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
975972 } ;
976973
977974 let mut llargs = Vec :: with_capacity ( arg_count) ;
978- let destination = target. as_ref ( ) . map ( |& target| {
979- (
980- self . make_return_dest (
981- bx,
982- destination,
983- & fn_abi. ret ,
984- & mut llargs,
985- None ,
986- Some ( target) ,
987- ) ,
988- target,
989- )
990- } ) ;
975+
976+ // We still need to call `make_return_dest` even if there's no `target`, since
977+ // `fn_abi.ret` could be `PassMode::Indirect`, even if it is uninhabited,
978+ // and `make_return_dest` adds the return-place indirect pointer to `llargs`.
979+ let return_dest = self . make_return_dest ( bx, destination, & fn_abi. ret , & mut llargs, None ) ;
980+ let destination = target. map ( |target| ( return_dest, target) ) ;
991981
992982 // Split the rust-call tupled arguments off.
993983 let ( first_args, untuple) = if abi == ExternAbi :: RustCall && !args. is_empty ( ) {
@@ -1790,11 +1780,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
17901780 fn_ret : & ArgAbi < ' tcx , Ty < ' tcx > > ,
17911781 llargs : & mut Vec < Bx :: Value > ,
17921782 intrinsic : Option < ty:: IntrinsicDef > ,
1793- target : Option < BasicBlock > ,
17941783 ) -> ReturnDest < ' tcx , Bx :: Value > {
1795- if target. is_none ( ) {
1796- return ReturnDest :: Nothing ;
1797- }
17981784 // If the return is ignored, we can just return a do-nothing `ReturnDest`.
17991785 if fn_ret. is_ignore ( ) {
18001786 return ReturnDest :: Nothing ;
0 commit comments