@@ -4,9 +4,7 @@ use rustc_abi::{BackendRepr, ExternAbi, HasDataLayout, Reg, WrappingRange};
4
4
use rustc_ast as ast;
5
5
use rustc_ast:: { InlineAsmOptions , InlineAsmTemplatePiece } ;
6
6
use 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 } ;
10
8
use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf , ValidityRequirement } ;
11
9
use rustc_middle:: ty:: print:: { with_no_trimmed_paths, with_no_visible_paths} ;
12
10
use rustc_middle:: ty:: { self , Instance , Ty } ;
@@ -919,7 +917,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
919
917
& fn_abi. ret ,
920
918
& mut llargs,
921
919
Some ( intrinsic) ,
922
- target,
923
920
) ;
924
921
let dest = match ret_dest {
925
922
_ if fn_abi. ret . is_indirect ( ) => llargs[ 0 ] ,
@@ -975,19 +972,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
975
972
} ;
976
973
977
974
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) ) ;
991
981
992
982
// Split the rust-call tupled arguments off.
993
983
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> {
1790
1780
fn_ret : & ArgAbi < ' tcx , Ty < ' tcx > > ,
1791
1781
llargs : & mut Vec < Bx :: Value > ,
1792
1782
intrinsic : Option < ty:: IntrinsicDef > ,
1793
- target : Option < BasicBlock > ,
1794
1783
) -> ReturnDest < ' tcx , Bx :: Value > {
1795
- if target. is_none ( ) {
1796
- return ReturnDest :: Nothing ;
1797
- }
1798
1784
// If the return is ignored, we can just return a do-nothing `ReturnDest`.
1799
1785
if fn_ret. is_ignore ( ) {
1800
1786
return ReturnDest :: Nothing ;
0 commit comments