@@ -775,6 +775,8 @@ pub fn trans_call_inner<'a>(
775775 // We trans them in place in `trans_intrinsic_call`
776776 assert ! ( abi != synabi:: RustIntrinsic ) ;
777777
778+ let is_rust_fn = abi == synabi:: Rust || abi == synabi:: RustCall ;
779+
778780 // Generate a location to store the result. If the user does
779781 // not care about the result, just make a stack slot.
780782 let opt_llretslot = match dest {
@@ -783,14 +785,17 @@ pub fn trans_call_inner<'a>(
783785 None
784786 }
785787 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) => {
787791 if !type_is_zero_size ( ccx, ret_ty) {
788792 Some ( alloc_ty ( bcx, ret_ty, "__llret" ) )
789793 } else {
790794 let llty = type_of:: type_of ( ccx, ret_ty) ;
791795 Some ( C_undef ( llty. ptr_to ( ) ) )
792796 }
793797 }
798+ Some ( expr:: Ignore ) => None
794799 } ;
795800
796801 let mut llresult = unsafe {
@@ -803,7 +808,7 @@ pub fn trans_call_inner<'a>(
803808 // and done, either the return value of the function will have been
804809 // written in opt_llretslot (if it is Some) or `llresult` will be
805810 // set appropriately (otherwise).
806- if abi == synabi :: Rust || abi == synabi :: RustCall {
811+ if is_rust_fn {
807812 let mut llargs = Vec :: new ( ) ;
808813
809814 // Push the out-pointer if we use an out-pointer for this
@@ -878,15 +883,12 @@ pub fn trans_call_inner<'a>(
878883
879884 // If the caller doesn't care about the result of this fn call,
880885 // 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) ) => {
886888 // 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) ;
888890 }
889- Some ( expr :: SaveIn ( _ ) ) => { }
891+ _ => { }
890892 }
891893
892894 if ty:: type_is_bot ( ret_ty) {
0 commit comments