Change:
() Errors: Probably related: Removing (at least) one of the s for makes the panic go away, and the compiler correctly reports the error: modify labels: I-ICE, T-compiler, A-const-eval, A-const-generics, C-bug, F-const_generics, requires-nightly
That's happening here: I don#t think there is a meaningful way to evaluate a polymorphic constant, so either some code earlier screwed up to even get so far, or we need to throw here. Cc
cc This ICE is totally expected. Using features that emit the lint are expected to ICE, otherwise they would not emit said lint. The const evaluator is not at fault here, there's just no way to evaluate this.
hmm, we shouldn't try to evaluate this constant here or at least have it be a instead of a . Not quite sure what's going on here, will have to look at it in more detail soon
So we probably fail here because we call with a which get's canonicalized to a . All of that seems correct to me :thinking: Is it possible that we should treat similar to and "just" return here?

Discussion:
tcx.layout_raw(param_env.and(normalized))? } <del> ty::Bound(..) | ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Infer(_) => { </del> <ins> ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Infer(_) => { </ins> bug!("Layout::compute: unexpected type `{}`", ty) } <del> ty::Param(_) | ty::Error(_) => { </del> <ins> ty::Bound(..) | ty::Param(_) | ty::Error(_) => { </ins> return Err(LayoutError::Unknown(ty)); } })

}; // Early-return cases. let val_val = match val.val { <del> ty::ConstKind::Param(_) => throw_inval!(TooGeneric), </del> <ins> ty::ConstKind::Param(_) | ty::ConstKind::Bound(..) => throw_inval!(TooGeneric), </ins> ty::ConstKind::Error(_) => throw_inval!(TypeckError(ErrorReported)), ty::ConstKind::Unevaluated(def, substs, promoted) => { let instance = self.resolve(def.did, substs)?;

// happening. return Ok(self.const_eval(GlobalId { instance, promoted }, val.ty)?); } <del> ty::ConstKind::Infer(..) | ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(..) => { </del> <ins> ty::ConstKind::Infer(..) | ty::ConstKind::Placeholder(..) => { </ins> span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", val) } ty::ConstKind::Value(val_val) => val_val,

<ins> // compile-flags: -Zsave-analysis #![feature(const_generics)] #![allow(incomplete_features)] struct Arr<const N: usize> where Assert::<{N < usize::max_value() / 2}>: IsTrue, //~ ERROR constant expression { } enum Assert<const CHECK: bool> {} trait IsTrue {} impl IsTrue for Assert<true> {} fn main() { let x: Arr<{usize::max_value()}> = Arr {}; //~^ ERROR mismatched types //~| ERROR mismatched types } </ins>

<ins> error: constant expression depends on a generic parameter --> $DIR/issue-73260.rs:6:47 | LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue, |                                               ^^^^^^ | = note: this may fail depending on what value the parameter takes error[E0308]: mismatched types --> $DIR/issue-73260.rs:17:12 | LL |     let x: Arr<{usize::max_value()}> = Arr {}; |            ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `false`, found `true` | = note: expected type `false` found type `true` error[E0308]: mismatched types --> $DIR/issue-73260.rs:17:40 | LL |     let x: Arr<{usize::max_value()}> = Arr {}; |                                        ^^^ expected `false`, found `true` | = note: expected type `false` found type `true` error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. </ins>

<ins> #![feature(const_generics)] #![allow(incomplete_features)] trait If<const COND: bool> {} impl If<true> for () {} trait IsZero<const N: u8> { type Answer; } struct True; struct False; impl<const N: u8> IsZero<N> for () where (): If<{N == 0}> { //~ERROR constant expression type Answer = True; } trait Foobar<const N: u8> {} impl<const N: u8> Foobar<N> for () where (): IsZero<N, Answer = True> {} impl<const N: u8> Foobar<N> for () where (): IsZero<N, Answer = False> {} fn main() {} </ins>

<ins> error: constant expression depends on a generic parameter --> $DIR/issue-74634.rs:15:11 | LL | where (): If<{N == 0}> { |           ^^^^^^^^^^^^ | = note: this may fail depending on what value the parameter takes error: aborting due to previous error </ins>

<ins> #![feature(const_generics, const_evaluatable_checked)] #![allow(incomplete_features)] struct Bool<const B: bool>; trait True {} impl True for Bool<true> {} fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True { todo!() } fn main() { test::<2>(); //~^ ERROR wrong number of type //~| ERROR constant expression depends } </ins>

<ins> error[E0107]: wrong number of type arguments: expected 1, found 0 --> $DIR/issue-76595.rs:15:5 | LL |     test::<2>(); |     ^^^^^^^^^ expected 1 type argument error: constant expression depends on a generic parameter --> $DIR/issue-76595.rs:15:5 | LL | fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True { |                                                                           ---- required by this bound in `test` ... LL |     test::<2>(); |     ^^^^^^^^^ | = note: this may fail depending on what value the parameter takes error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0107`. </ins>