@@ -730,7 +730,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
730
730
& mut self ,
731
731
helper : & TerminatorCodegenHelper < ' tcx > ,
732
732
bx : & mut Bx ,
733
- intrinsic : Option < ty:: IntrinsicDef > ,
733
+ intrinsic : ty:: IntrinsicDef ,
734
734
instance : Option < Instance < ' tcx > > ,
735
735
source_info : mir:: SourceInfo ,
736
736
target : Option < mir:: BasicBlock > ,
@@ -740,8 +740,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
740
740
// Emit a panic or a no-op for `assert_*` intrinsics.
741
741
// These are intrinsics that compile to panics so that we can get a message
742
742
// which mentions the offending type, even from a const context.
743
- let panic_intrinsic = intrinsic. and_then ( |i| ValidityRequirement :: from_intrinsic ( i. name ) ) ;
744
- if let Some ( requirement) = panic_intrinsic {
743
+ if let Some ( requirement) = ValidityRequirement :: from_intrinsic ( intrinsic. name ) {
745
744
let ty = instance. unwrap ( ) . args . type_at ( 0 ) ;
746
745
747
746
let do_panic = !bx
@@ -845,12 +844,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
845
844
let sig = callee. layout . ty . fn_sig ( bx. tcx ( ) ) ;
846
845
let abi = sig. abi ( ) ;
847
846
848
- // Handle intrinsics old codegen wants Expr's for, ourselves.
849
- let intrinsic = match def {
850
- Some ( ty:: InstanceDef :: Intrinsic ( def_id) ) => Some ( bx. tcx ( ) . intrinsic ( def_id) . unwrap ( ) ) ,
851
- _ => None ,
852
- } ;
853
-
854
847
let extra_args = & args[ sig. inputs ( ) . skip_binder ( ) . len ( ) ..] ;
855
848
let extra_args = bx. tcx ( ) . mk_type_list_from_iter ( extra_args. iter ( ) . map ( |op_arg| {
856
849
let op_ty = op_arg. node . ty ( self . mir , bx. tcx ( ) ) ;
@@ -862,25 +855,25 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
862
855
None => bx. fn_abi_of_fn_ptr ( sig, extra_args) ,
863
856
} ;
864
857
865
- if let Some ( merging_succ) = self . codegen_panic_intrinsic (
866
- & helper,
867
- bx,
868
- intrinsic,
869
- instance,
870
- source_info,
871
- target,
872
- unwind,
873
- mergeable_succ,
874
- ) {
875
- return merging_succ;
876
- }
877
-
878
858
// The arguments we'll be passing. Plus one to account for outptr, if used.
879
859
let arg_count = fn_abi. args . len ( ) + fn_abi. ret . is_indirect ( ) as usize ;
880
860
881
- let instance = match intrinsic {
882
- None => instance,
883
- Some ( intrinsic) => {
861
+ let instance = match def {
862
+ Some ( ty:: InstanceDef :: Intrinsic ( def_id) ) => {
863
+ let intrinsic = bx. tcx ( ) . intrinsic ( def_id) . unwrap ( ) ;
864
+ if let Some ( merging_succ) = self . codegen_panic_intrinsic (
865
+ & helper,
866
+ bx,
867
+ intrinsic,
868
+ instance,
869
+ source_info,
870
+ target,
871
+ unwind,
872
+ mergeable_succ,
873
+ ) {
874
+ return merging_succ;
875
+ }
876
+
884
877
let mut llargs = Vec :: with_capacity ( 1 ) ;
885
878
let ret_dest = self . make_return_dest (
886
879
bx,
@@ -960,6 +953,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
960
953
}
961
954
}
962
955
}
956
+ _ => instance,
963
957
} ;
964
958
965
959
let mut llargs = Vec :: with_capacity ( arg_count) ;
0 commit comments