@@ -282,10 +282,8 @@ fn verify_func(tcx: TyCtxt<'_>, writer: &crate::pretty_clif::CommentWriter, func
282282}
283283
284284fn codegen_fn_body ( fx : & mut FunctionCx < ' _ , ' _ , ' _ > , start_block : Block ) {
285- let arg_uninhabited = fx
286- . mir
287- . args_iter ( )
288- . any ( |arg| fx. layout_of ( fx. monomorphize ( fx. mir . local_decls [ arg] . ty ) ) . is_uninhabited ( ) ) ;
285+ let arg_uninhabited =
286+ fx. mir . args_iter ( ) . any ( |arg| fx. layout_of ( fx. mir . local_decls [ arg] . ty ) . is_uninhabited ( ) ) ;
289287 if arg_uninhabited {
290288 fx. bcx . append_block_params_for_function_params ( fx. block_map [ START_BLOCK ] ) ;
291289 fx. bcx . switch_to_block ( fx. block_map [ START_BLOCK ] ) ;
@@ -689,8 +687,8 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
689687 ref operand,
690688 to_ty,
691689 ) => {
692- let from_ty = fx . monomorphize ( operand. ty ( & fx. mir . local_decls , fx. tcx ) ) ;
693- let to_layout = fx. layout_of ( fx . monomorphize ( to_ty) ) ;
690+ let from_ty = operand. ty ( & fx. mir . local_decls , fx. tcx ) ;
691+ let to_layout = fx. layout_of ( to_ty) ;
694692 match * from_ty. kind ( ) {
695693 ty:: FnDef ( def_id, args) => {
696694 let func_ref = fx. get_function_ref (
@@ -713,7 +711,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
713711 ref operand,
714712 to_ty,
715713 ) => {
716- let to_layout = fx. layout_of ( fx . monomorphize ( to_ty) ) ;
714+ let to_layout = fx. layout_of ( to_ty) ;
717715 let operand = codegen_operand ( fx, operand) ;
718716 lval. write_cvalue ( fx, operand. cast_pointer_to ( to_layout) ) ;
719717 }
@@ -743,7 +741,6 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
743741 ) => {
744742 let operand = codegen_operand ( fx, operand) ;
745743 let from_ty = operand. layout ( ) . ty ;
746- let to_ty = fx. monomorphize ( to_ty) ;
747744
748745 fn is_wide_ptr < ' tcx > ( fx : & FunctionCx < ' _ , ' _ , ' tcx > , ty : Ty < ' tcx > ) -> bool {
749746 ty. builtin_deref ( true ) . is_some_and ( |pointee_ty| {
@@ -815,8 +812,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
815812 }
816813 Rvalue :: Repeat ( ref operand, times) => {
817814 let operand = codegen_operand ( fx, operand) ;
818- let times = fx
819- . monomorphize ( times)
815+ let times = times
820816 . try_to_target_usize ( fx. tcx )
821817 . expect ( "expected monomorphic const in codegen" ) ;
822818 if operand. layout ( ) . size . bytes ( ) == 0 {
@@ -853,7 +849,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
853849 if matches ! ( * * kind, AggregateKind :: RawPtr ( ..) ) =>
854850 {
855851 let ty = to_place_and_rval. 1 . ty ( & fx. mir . local_decls , fx. tcx ) ;
856- let layout = fx. layout_of ( fx . monomorphize ( ty ) ) ;
852+ let layout = fx. layout_of ( ty ) ;
857853 let [ data, meta] = & * operands. raw else {
858854 bug ! ( "RawPtr fields: {operands:?}" ) ;
859855 } ;
@@ -948,8 +944,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
948944fn codegen_array_len < ' tcx > ( fx : & mut FunctionCx < ' _ , ' _ , ' tcx > , place : CPlace < ' tcx > ) -> Value {
949945 match * place. layout ( ) . ty . kind ( ) {
950946 ty:: Array ( _elem_ty, len) => {
951- let len = fx
952- . monomorphize ( len)
947+ let len = len
953948 . try_to_target_usize ( fx. tcx )
954949 . expect ( "expected monomorphic const in codegen" ) as i64 ;
955950 fx. bcx . ins ( ) . iconst ( fx. pointer_type , len)
@@ -972,7 +967,7 @@ pub(crate) fn codegen_place<'tcx>(
972967 }
973968 PlaceElem :: OpaqueCast ( ty) => bug ! ( "encountered OpaqueCast({ty}) in codegen" ) ,
974969 PlaceElem :: UnwrapUnsafeBinder ( ty) => {
975- cplace = cplace. place_transmute_type ( fx, fx . monomorphize ( ty ) ) ;
970+ cplace = cplace. place_transmute_type ( fx, ty ) ;
976971 }
977972 PlaceElem :: Field ( field, _ty) => {
978973 cplace = cplace. place_field ( fx, field) ;
0 commit comments