@@ -446,8 +446,8 @@ pub fn trans_call(in_cx: block,
446
446
node_id_type ( in_cx, id) ,
447
447
|cx| trans ( cx, f) ,
448
448
args,
449
- dest,
450
- DontAutorefArg )
449
+ Some ( dest) ,
450
+ DontAutorefArg ) . bcx
451
451
}
452
452
453
453
pub fn trans_method_call ( in_cx : block ,
@@ -484,15 +484,15 @@ pub fn trans_method_call(in_cx: block,
484
484
}
485
485
} ,
486
486
args,
487
- dest,
488
- DontAutorefArg )
487
+ Some ( dest) ,
488
+ DontAutorefArg ) . bcx
489
489
}
490
490
491
491
pub fn trans_lang_call ( bcx : block ,
492
492
did : ast:: def_id ,
493
493
args : & [ ValueRef ] ,
494
- dest : expr:: Dest )
495
- -> block {
494
+ dest : Option < expr:: Dest > )
495
+ -> Result {
496
496
let fty = if did. crate == ast:: local_crate {
497
497
ty:: node_id_to_type ( bcx. ccx ( ) . tcx , did. node )
498
498
} else {
@@ -552,7 +552,7 @@ pub fn trans_lang_call_with_type_params(bcx: block,
552
552
}
553
553
Callee { bcx : callee. bcx , data : Fn ( FnData { llfn : new_llval } ) }
554
554
} ,
555
- ArgVals ( args) , dest, DontAutorefArg ) ;
555
+ ArgVals ( args) , Some ( dest) , DontAutorefArg ) . bcx ;
556
556
}
557
557
558
558
pub fn body_contains_ret ( body : & ast:: blk ) -> bool {
@@ -579,10 +579,10 @@ pub fn trans_call_inner(in_cx: block,
579
579
ret_ty : ty:: t ,
580
580
get_callee : & fn ( block ) -> Callee ,
581
581
args : CallArgs ,
582
- dest : expr:: Dest ,
582
+ dest : Option < expr:: Dest > ,
583
583
autoref_arg : AutorefArg )
584
- -> block {
585
- do base:: with_scope ( in_cx, call_info, "call" ) |cx| {
584
+ -> Result {
585
+ do base:: with_scope_result ( in_cx, call_info, "call" ) |cx| {
586
586
let ret_in_loop = match args {
587
587
ArgExprs ( args) => {
588
588
args. len ( ) > 0 u && match args. last ( ) . node {
@@ -669,18 +669,12 @@ pub fn trans_call_inner(in_cx: block,
669
669
bcx = new_bcx;
670
670
671
671
match dest {
672
- expr:: Ignore => {
672
+ None => { assert ! ( ty:: type_is_immediate( bcx. tcx( ) , ret_ty) ) }
673
+ Some ( expr:: Ignore ) => {
673
674
// drop the value if it is not being saved.
674
675
unsafe {
675
- if llvm:: LLVMIsUndef ( llretslot) != lib:: llvm:: True {
676
- if ty:: type_is_nil ( ret_ty) {
677
- // When implementing the for-loop sugar syntax, the
678
- // type of the for-loop is nil, but the function
679
- // it's invoking returns a bool. This is a special
680
- // case to ignore instead of invoking the Store
681
- // below into a scratch pointer of a mismatched
682
- // type.
683
- } else if ty:: type_is_immediate ( bcx. tcx ( ) , ret_ty) {
676
+ if ty:: type_needs_drop ( bcx. tcx ( ) , ret_ty) {
677
+ if ty:: type_is_immediate ( bcx. tcx ( ) , ret_ty) {
684
678
let llscratchptr = alloc_ty ( bcx, ret_ty) ;
685
679
Store ( bcx, llresult, llscratchptr) ;
686
680
bcx = glue:: drop_ty ( bcx, llscratchptr, ret_ty) ;
@@ -690,7 +684,7 @@ pub fn trans_call_inner(in_cx: block,
690
684
}
691
685
}
692
686
}
693
- expr:: SaveIn ( lldest) => {
687
+ Some ( expr:: SaveIn ( lldest) ) => {
694
688
// If this is an immediate, store into the result location.
695
689
// (If this was not an immediate, the result will already be
696
690
// directly written into the output slot.)
@@ -717,7 +711,7 @@ pub fn trans_call_inner(in_cx: block,
717
711
bcx
718
712
}
719
713
}
720
- bcx
714
+ rslt ( bcx, llresult )
721
715
}
722
716
}
723
717
@@ -727,14 +721,14 @@ pub enum CallArgs<'self> {
727
721
ArgVals ( & ' self [ ValueRef ] )
728
722
}
729
723
730
- pub fn trans_ret_slot( bcx: block, fn_ty: ty:: t, dest: expr:: Dest )
724
+ pub fn trans_ret_slot( bcx: block, fn_ty: ty:: t, dest: Option < expr:: Dest > )
731
725
-> ValueRef {
732
726
let retty = ty:: ty_fn_ret( fn_ty) ;
733
727
734
728
match dest {
735
- expr : : SaveIn ( dst) => dst,
736
- expr : : Ignore => {
737
- if ty:: type_is_nil ( retty) {
729
+ Some ( expr:: SaveIn ( dst) ) => dst,
730
+ _ => {
731
+ if ty:: type_is_immediate ( bcx . tcx ( ) , retty) {
738
732
unsafe {
739
733
llvm:: LLVMGetUndef ( Type :: nil( ) . ptr_to( ) . to_ref( ) )
740
734
}
0 commit comments