Skip to content

Commit b7cc765

Browse files
committed
don't point at const usage site for resolution-time errors
also share the code that emits the actual error
1 parent 3113fef commit b7cc765

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/base.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use rustc_ast::InlineAsmOptions;
44
use rustc_index::IndexVec;
5-
use rustc_middle::mir::interpret::ErrorHandled;
65
use rustc_middle::ty::adjustment::PointerCoercion;
76
use rustc_middle::ty::layout::FnAbiOf;
87
use rustc_middle::ty::print::with_no_trimmed_paths;
@@ -251,21 +250,15 @@ pub(crate) fn verify_func(
251250
}
252251

253252
fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
254-
match fx.mir.post_mono_checks(fx.tcx, ty::ParamEnv::reveal_all(), |c| Ok(fx.monomorphize(c))) {
255-
Ok(()) => {}
256-
Err(ErrorHandled::TooGeneric(span)) => {
257-
span_bug!(span, "codegen encountered polymorphic constant");
258-
}
259-
Err(ErrorHandled::Reported(info, span)) => {
260-
if !info.is_tainted_by_errors() {
261-
fx.tcx.sess.span_err(span, "erroneous constant encountered");
262-
}
263-
fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]);
264-
fx.bcx.switch_to_block(fx.block_map[START_BLOCK]);
265-
// compilation should have been aborted
266-
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
267-
return;
268-
}
253+
if let Err(err) =
254+
fx.mir.post_mono_checks(fx.tcx, ty::ParamEnv::reveal_all(), |c| Ok(fx.monomorphize(c)))
255+
{
256+
err.emit_err(fx.tcx);
257+
fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]);
258+
fx.bcx.switch_to_block(fx.block_map[START_BLOCK]);
259+
// compilation should have been aborted
260+
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
261+
return;
269262
}
270263

271264
let arg_uninhabited = fx

0 commit comments

Comments
 (0)