Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --I encountered an ICE while playing with 's that has to do with its comptime assertions. I have not been able to reproduce the ICE when inlining the constant value in which the checks are performed. Perhaps it is related with the fact that originally there was a crate boundary? I have an inkling const blocks' merger might be to blame. <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
It would be useful to have a minimal example that doesn't involve the entire tagged_ptr crate.
Reduced: , needs This bisects to cc label A-monomorphization S-has-mcve -E-needs-mcve
ye olde "compiler must not crash on invalid code" problem
PR with a fix is up. Thanks for catching this before the bug hit beta
No, thanks to you all for not only fixing it, but running this amazing project every day. I hope I have more time in the future so that I can spend it here and be a part of this.

Discussion:
env, crate::ty::EarlyBinder::bind(constant.const_), ); <del> let Some(bits) = mono_literal.try_eval_bits(tcx, env) else { bug!("Couldn't evaluate constant {:?} in mono {:?}", constant, instance); }; bits </del> <ins> mono_literal.try_eval_bits(tcx, env) </ins> }; let TerminatorKind::SwitchInt { discr, targets } = &block.terminator().kind else {

// If this is a SwitchInt(const _), then we can just evaluate the constant and return. let discr = match discr { Operand::Constant(constant) => { <del> let bits = eval_mono_const(constant); </del> <ins> let bits = eval_mono_const(constant)?; </ins> return Some((bits, targets)); } Operand::Move(place) | Operand::Copy(place) => place,

match rvalue { Rvalue::NullaryOp(NullOp::UbChecks, _) => Some((tcx.sess.ub_checks() as u128, targets)), Rvalue::Use(Operand::Constant(constant)) => { <del> let bits = eval_mono_const(constant); </del> <ins> let bits = eval_mono_const(constant)?; </ins> Some((bits, targets)) } _ => None,

<ins> //@ build-fail struct Bar<const BITS: usize>; impl<const BITS: usize> Bar<BITS> { const ASSERT: bool = { let b = std::convert::identity(1); ["oops"][b]; //~ ERROR evaluation of `Bar::<0>::ASSERT` failed true }; fn assert() { let val = Self::ASSERT; if val { std::convert::identity(val); } } } fn main() { Bar::<0>::assert(); } </ins>

<ins> error[E0080]: evaluation of `Bar::<0>::ASSERT` failed --> $DIR/mono-reachable-invalid-const.rs:8:9 | LL |         ["oops"][b]; |         ^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 note: erroneous constant encountered --> $DIR/mono-reachable-invalid-const.rs:13:19 | LL |         let val = Self::ASSERT; |                   ^^^^^^^^^^^^ note: erroneous constant encountered --> $DIR/mono-reachable-invalid-const.rs:13:19 | LL |         let val = Self::ASSERT; |                   ^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: the above error was encountered while instantiating `fn Bar::<0>::assert` --> $DIR/mono-reachable-invalid-const.rs:22:5 | LL |     Bar::<0>::assert(); |     ^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. </ins>