@@ -730,7 +730,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
730730 & mut self ,
731731 helper : & TerminatorCodegenHelper < ' tcx > ,
732732 bx : & mut Bx ,
733- intrinsic : Option < ty:: IntrinsicDef > ,
733+ intrinsic : ty:: IntrinsicDef ,
734734 instance : Option < Instance < ' tcx > > ,
735735 source_info : mir:: SourceInfo ,
736736 target : Option < mir:: BasicBlock > ,
@@ -740,8 +740,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
740740 // Emit a panic or a no-op for `assert_*` intrinsics.
741741 // These are intrinsics that compile to panics so that we can get a message
742742 // 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 ) {
745744 let ty = instance. unwrap ( ) . args . type_at ( 0 ) ;
746745
747746 let do_panic = !bx
@@ -845,12 +844,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
845844 let sig = callee. layout . ty . fn_sig ( bx. tcx ( ) ) ;
846845 let abi = sig. abi ( ) ;
847846
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-
854847 let extra_args = & args[ sig. inputs ( ) . skip_binder ( ) . len ( ) ..] ;
855848 let extra_args = bx. tcx ( ) . mk_type_list_from_iter ( extra_args. iter ( ) . map ( |op_arg| {
856849 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> {
862855 None => bx. fn_abi_of_fn_ptr ( sig, extra_args) ,
863856 } ;
864857
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-
878858 // The arguments we'll be passing. Plus one to account for outptr, if used.
879859 let arg_count = fn_abi. args . len ( ) + fn_abi. ret . is_indirect ( ) as usize ;
880860
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+
884877 let mut llargs = Vec :: with_capacity ( 1 ) ;
885878 let ret_dest = self . make_return_dest (
886879 bx,
@@ -960,6 +953,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
960953 }
961954 }
962955 }
956+ _ => instance,
963957 } ;
964958
965959 let mut llargs = Vec :: with_capacity ( arg_count) ;
0 commit comments