diff --git a/src/base.rs b/src/base.rs index e41c6b31e9c..9b5a6b89191 100644 --- a/src/base.rs +++ b/src/base.rs @@ -2,7 +2,6 @@ use rustc_ast::InlineAsmOptions; use rustc_index::IndexVec; -use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; @@ -251,21 +250,15 @@ pub(crate) fn verify_func( } fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { - match fx.mir.post_mono_checks(fx.tcx, ty::ParamEnv::reveal_all(), |c| Ok(fx.monomorphize(c))) { - Ok(()) => {} - Err(ErrorHandled::TooGeneric(span)) => { - span_bug!(span, "codegen encountered polymorphic constant"); - } - Err(ErrorHandled::Reported(info, span)) => { - if !info.is_tainted_by_errors() { - fx.tcx.sess.span_err(span, "erroneous constant encountered"); - } - fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]); - fx.bcx.switch_to_block(fx.block_map[START_BLOCK]); - // compilation should have been aborted - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); - return; - } + if let Err(err) = + fx.mir.post_mono_checks(fx.tcx, ty::ParamEnv::reveal_all(), |c| Ok(fx.monomorphize(c))) + { + err.emit_err(fx.tcx); + fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]); + fx.bcx.switch_to_block(fx.block_map[START_BLOCK]); + // compilation should have been aborted + fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + return; } let arg_uninhabited = fx