Do not ICE on invalid consts when walking mono-reachable blocks
This commit is contained in:
parent
ef8b9dcf23
commit
82cc02a60b
3 changed files with 55 additions and 6 deletions
|
@ -701,10 +701,7 @@ impl<'tcx> Body<'tcx> {
|
|||
env,
|
||||
crate::ty::EarlyBinder::bind(constant.const_),
|
||||
);
|
||||
let Some(bits) = mono_literal.try_eval_bits(tcx, env) else {
|
||||
bug!("Couldn't evaluate constant {:?} in mono {:?}", constant, instance);
|
||||
};
|
||||
bits
|
||||
mono_literal.try_eval_bits(tcx, env)
|
||||
};
|
||||
|
||||
let TerminatorKind::SwitchInt { discr, targets } = &block.terminator().kind else {
|
||||
|
@ -714,7 +711,7 @@ impl<'tcx> Body<'tcx> {
|
|||
// If this is a SwitchInt(const _), then we can just evaluate the constant and return.
|
||||
let discr = match discr {
|
||||
Operand::Constant(constant) => {
|
||||
let bits = eval_mono_const(constant);
|
||||
let bits = eval_mono_const(constant)?;
|
||||
return Some((bits, targets));
|
||||
}
|
||||
Operand::Move(place) | Operand::Copy(place) => place,
|
||||
|
@ -748,7 +745,7 @@ impl<'tcx> Body<'tcx> {
|
|||
match rvalue {
|
||||
Rvalue::NullaryOp(NullOp::UbChecks, _) => Some((tcx.sess.ub_checks() as u128, targets)),
|
||||
Rvalue::Use(Operand::Constant(constant)) => {
|
||||
let bits = eval_mono_const(constant);
|
||||
let bits = eval_mono_const(constant)?;
|
||||
Some((bits, targets))
|
||||
}
|
||||
_ => None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue