Skip to content

Commit b5ef239

Browse files
committed
Fix ICE on invalid const param types
1 parent 3a36386 commit b5ef239

File tree

1 file changed

+18
-0
lines changed
  • compiler/rustc_hir_analysis/src/hir_ty_lowering

1 file changed

+18
-0
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,24 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
551551
if let Err(guar) = ty.error_reported() {
552552
return ty::Const::new_error(tcx, guar, ty).into();
553553
}
554+
555+
let param_span = match tcx.hir().span_if_local(param.def_id) {
556+
Some(sp) => sp,
557+
_ => self.span,
558+
};
559+
560+
// Ensure that the const param does not have an unsupported
561+
// type or we ICE later (see #123863)
562+
if !tcx.features().adt_const_params
563+
&& !matches!(ty.kind(), ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_))
564+
{
565+
let guar = tcx.dcx().span_delayed_bug(
566+
param_span,
567+
"Const param has unsupported type but no error emitted",
568+
);
569+
return ty::Const::new_error(tcx, guar, ty).into();
570+
};
571+
554572
// FIXME(effects) see if we should special case effect params here
555573
if !infer_args && has_default {
556574
tcx.const_param_default(param.def_id)

0 commit comments

Comments
 (0)