@@ -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 } ;
@@ -942,7 +940,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
942940 & fn_abi. ret ,
943941 & mut llargs,
944942 Some ( intrinsic) ,
945- target,
946943 ) ;
947944 let dest = match ret_dest {
948945 _ if fn_abi. ret . is_indirect ( ) => llargs[ 0 ] ,
@@ -998,19 +995,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
998995 } ;
999996
1000997 let mut llargs = Vec :: with_capacity ( arg_count) ;
1001- let destination = target. as_ref ( ) . map ( |& target| {
1002- (
1003- self . make_return_dest (
1004- bx,
1005- destination,
1006- & fn_abi. ret ,
1007- & mut llargs,
1008- None ,
1009- Some ( target) ,
1010- ) ,
1011- target,
1012- )
1013- } ) ;
998+
999+ // We still need to call `make_return_dest` even if there's no `target`, since
1000+ // `fn_abi.ret` could be `PassMode::Indirect`, even if it is uninhabited,
1001+ // and `make_return_dest` adds the return-place indirect pointer to `llargs`.
1002+ let return_dest = self . make_return_dest ( bx, destination, & fn_abi. ret , & mut llargs, None ) ;
1003+ let destination = target. map ( |target| ( return_dest, target) ) ;
10141004
10151005 // Split the rust-call tupled arguments off.
10161006 let ( first_args, untuple) = if abi == ExternAbi :: RustCall && !args. is_empty ( ) {
@@ -1813,11 +1803,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
18131803 fn_ret : & ArgAbi < ' tcx , Ty < ' tcx > > ,
18141804 llargs : & mut Vec < Bx :: Value > ,
18151805 intrinsic : Option < ty:: IntrinsicDef > ,
1816- target : Option < BasicBlock > ,
18171806 ) -> ReturnDest < ' tcx , Bx :: Value > {
1818- if target. is_none ( ) {
1819- return ReturnDest :: Nothing ;
1820- }
18211807 // If the return is ignored, we can just return a do-nothing `ReturnDest`.
18221808 if fn_ret. is_ignore ( ) {
18231809 return ReturnDest :: Nothing ;
0 commit comments