@@ -775,6 +775,8 @@ pub fn trans_call_inner<'a>(
775
775
// We trans them in place in `trans_intrinsic_call`
776
776
assert ! ( abi != synabi:: RustIntrinsic ) ;
777
777
778
+ let is_rust_fn = abi == synabi:: Rust || abi == synabi:: RustCall ;
779
+
778
780
// Generate a location to store the result. If the user does
779
781
// not care about the result, just make a stack slot.
780
782
let opt_llretslot = match dest {
@@ -783,14 +785,17 @@ pub fn trans_call_inner<'a>(
783
785
None
784
786
}
785
787
Some ( expr:: SaveIn ( dst) ) => Some ( dst) ,
786
- Some ( expr:: Ignore ) => {
788
+ Some ( expr:: Ignore ) if !is_rust_fn ||
789
+ type_of:: return_uses_outptr ( ccx, ret_ty) ||
790
+ ty:: type_needs_drop ( bcx. tcx ( ) , ret_ty) => {
787
791
if !type_is_zero_size ( ccx, ret_ty) {
788
792
Some ( alloc_ty ( bcx, ret_ty, "__llret" ) )
789
793
} else {
790
794
let llty = type_of:: type_of ( ccx, ret_ty) ;
791
795
Some ( C_undef ( llty. ptr_to ( ) ) )
792
796
}
793
797
}
798
+ Some ( expr:: Ignore ) => None
794
799
} ;
795
800
796
801
let mut llresult = unsafe {
@@ -803,7 +808,7 @@ pub fn trans_call_inner<'a>(
803
808
// and done, either the return value of the function will have been
804
809
// written in opt_llretslot (if it is Some) or `llresult` will be
805
810
// set appropriately (otherwise).
806
- if abi == synabi :: Rust || abi == synabi :: RustCall {
811
+ if is_rust_fn {
807
812
let mut llargs = Vec :: new ( ) ;
808
813
809
814
// Push the out-pointer if we use an out-pointer for this
@@ -878,15 +883,13 @@ pub fn trans_call_inner<'a>(
878
883
879
884
// If the caller doesn't care about the result of this fn call,
880
885
// drop the temporary slot we made.
881
- match dest {
882
- None => {
883
- assert ! ( !type_of:: return_uses_outptr( bcx. ccx( ) , ret_ty) ) ;
884
- }
885
- Some ( expr:: Ignore ) => {
886
+ match ( dest, opt_llretslot) {
887
+ ( Some ( expr:: Ignore ) , Some ( llretslot) ) => {
886
888
// drop the value if it is not being saved.
887
- bcx = glue:: drop_ty ( bcx, opt_llretslot. unwrap ( ) , ret_ty) ;
889
+ bcx = glue:: drop_ty ( bcx, llretslot, ret_ty) ;
890
+ call_lifetime_end ( bcx, llretslot) ;
888
891
}
889
- Some ( expr :: SaveIn ( _ ) ) => { }
892
+ _ => { }
890
893
}
891
894
892
895
if ty:: type_is_bot ( ret_ty) {
0 commit comments