@@ -751,7 +751,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
751751 & mut self ,
752752 helper : & TerminatorCodegenHelper < ' tcx > ,
753753 bx : & mut Bx ,
754- intrinsic : Option < ty:: IntrinsicDef > ,
754+ intrinsic : ty:: IntrinsicDef ,
755755 instance : Option < Instance < ' tcx > > ,
756756 source_info : mir:: SourceInfo ,
757757 target : Option < mir:: BasicBlock > ,
@@ -761,8 +761,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
761761 // Emit a panic or a no-op for `assert_*` intrinsics.
762762 // These are intrinsics that compile to panics so that we can get a message
763763 // which mentions the offending type, even from a const context.
764- let panic_intrinsic = intrinsic. and_then ( |i| ValidityRequirement :: from_intrinsic ( i. name ) ) ;
765- if let Some ( requirement) = panic_intrinsic {
764+ if let Some ( requirement) = ValidityRequirement :: from_intrinsic ( intrinsic. name ) {
766765 let ty = instance. unwrap ( ) . args . type_at ( 0 ) ;
767766
768767 let do_panic = !bx
@@ -869,12 +868,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
869868 let sig = callee. layout . ty . fn_sig ( bx. tcx ( ) ) ;
870869 let abi = sig. abi ( ) ;
871870
872- // Handle intrinsics old codegen wants Expr's for, ourselves.
873- let intrinsic = match def {
874- Some ( ty:: InstanceKind :: Intrinsic ( def_id) ) => Some ( bx. tcx ( ) . intrinsic ( def_id) . unwrap ( ) ) ,
875- _ => None ,
876- } ;
877-
878871 let extra_args = & args[ sig. inputs ( ) . skip_binder ( ) . len ( ) ..] ;
879872 let extra_args = bx. tcx ( ) . mk_type_list_from_iter ( extra_args. iter ( ) . map ( |op_arg| {
880873 let op_ty = op_arg. node . ty ( self . mir , bx. tcx ( ) ) ;
@@ -886,25 +879,25 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
886879 None => bx. fn_abi_of_fn_ptr ( sig, extra_args) ,
887880 } ;
888881
889- if let Some ( merging_succ) = self . codegen_panic_intrinsic (
890- & helper,
891- bx,
892- intrinsic,
893- instance,
894- source_info,
895- target,
896- unwind,
897- mergeable_succ,
898- ) {
899- return merging_succ;
900- }
901-
902882 // The arguments we'll be passing. Plus one to account for outptr, if used.
903883 let arg_count = fn_abi. args . len ( ) + fn_abi. ret . is_indirect ( ) as usize ;
904884
905- let instance = match intrinsic {
906- None => instance,
907- Some ( intrinsic) => {
885+ let instance = match def {
886+ Some ( ty:: InstanceKind :: Intrinsic ( def_id) ) => {
887+ let intrinsic = bx. tcx ( ) . intrinsic ( def_id) . unwrap ( ) ;
888+ if let Some ( merging_succ) = self . codegen_panic_intrinsic (
889+ & helper,
890+ bx,
891+ intrinsic,
892+ instance,
893+ source_info,
894+ target,
895+ unwind,
896+ mergeable_succ,
897+ ) {
898+ return merging_succ;
899+ }
900+
908901 let mut llargs = Vec :: with_capacity ( 1 ) ;
909902 let ret_dest = self . make_return_dest (
910903 bx,
@@ -984,6 +977,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
984977 }
985978 }
986979 }
980+ _ => instance,
987981 } ;
988982
989983 let mut llargs = Vec :: with_capacity ( arg_count) ;
0 commit comments