{"id":"44b20fd2c442912d","repo":"rust-lang/rust","slug":"feature-generic-const-exprs-is-not-supported-in","errorCode":null,"errorMessage":"`feature(generic_const_exprs)` is not supported in the new trait solver","messagePattern":"`feature\\(generic_const_exprs\\)` is not supported in the new trait solver","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_next_trait_solver/src/solve/mod.rs","lineNumber":269,"sourceCode":"\n        let ct_ty = match ct.kind() {\n            ty::ConstKind::Infer(_) => {\n                return self\n                    .evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)\n                    .map_err(Into::into);\n            }\n            ty::ConstKind::Error(_) => {\n                return self\n                    .evaluate_added_goals_and_make_canonical_response(Certainty::Yes)\n                    .map_err(Into::into);\n            }\n            ty::ConstKind::Alias(ty::IsRigid::Yes, alias_const) => {\n                alias_const.type_of(self.cx()).skip_norm_wip()\n            }\n            ty::ConstKind::Alias(ty::IsRigid::No, _) => unimplemented!(\n                \"non-rigid unevaluated constant for compute_const_arg_has_type_goal: {ct:?}\"\n            ),\n            ty::ConstKind::Expr(_) => unimplemented!(\n                \"`feature(generic_const_exprs)` is not supported in the new trait solver\"\n            ),\n            ty::ConstKind::Param(_) => {\n                unreachable!(\"`ConstKind::Param` should have been canonicalized to `Placeholder`\")\n            }\n            ty::ConstKind::Bound(_, _) => panic!(\"escaping bound vars in {:?}\", ct),\n            ty::ConstKind::Value(cv) => cv.ty(),\n            ty::ConstKind::Placeholder(placeholder) => {\n                placeholder.find_const_ty_from_env(goal.param_env)\n            }\n        };\n\n        self.eq(goal.param_env, ct_ty, ty)?;\n        self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes).map_err(Into::into)\n    }\n}\n\n#[derive(Debug)]","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/mod.rs#L251-L287","documentation":"Explicit unimplemented! guard: the unstable feature(generic_const_exprs) (const expressions in generic positions, e.g. `[T; N + 1]`) is not yet supported by the next trait solver. compute_const_arg_has_type_goal bails when it sees a ConstKind::Expr, which is the IR node produced by that feature. Unlike the other panics here, this is an intentional, user-facing limitation rather than a solver invariant.","triggerScenarios":"Triggered when a crate with #![feature(generic_const_exprs)] (or any code path emitting ConstKind::Expr) is compiled with -Znext-solver enabled and a const-arg-has-type goal reaches the Expr arm at compiler/rustc_next_trait_solver/src/solve/mod.rs:269.","commonSituations":"Users enabling both #![feature(generic_const_exprs)] and the next trait solver in the same compilation. Common when experimenting on nightly with const generics (e.g. generic array sizes expressed as expressions) while also testing -Znext-solver.","solutions":["Do not combine #![feature(generic_const_exprs)] with -Znext-solver; remove the feature attribute or disable the solver.","Replace generic const expressions with concrete consts or associated consts that do not produce ConstKind::Expr.","Wait for / contribute to the upstream implementation tracking generic_const_exprs in the new solver.","If you must keep the feature, compile the affected crate with the old solver (no -Znext-solver, or -Znext-solver=coherence to limit its scope)."],"exampleFix":"// before: generic const expr + next-solver -> ICE\n#![feature(generic_const_exprs)]\nstruct S<const N: usize> { a: [u8; N + 1] } // N + 1 is a ConstKind::Expr\n\n// after: drop the feature and use a plain const parameter\nstruct S<const N: usize> { a: [u8; N] } // caller passes the full size directly","handlingStrategy":"validation","validationCode":"// `feature(generic_const_exprs)` is incompatible with the new trait solver.\n// Block the build if both are present.\nfn uses_generic_const_exprs(src: &str) -> bool {\n    src.contains(\"#!feature(generic_const_exprs)\") || src.contains(\"#[feature(generic_const_exprs)]\")\n}\nfn next_solver_active() -> bool {\n    std::env::var(\"RUSTFLAGS\").unwrap_or_default().contains(\"next-solver\")\n}\n#[test]\nfn no_gce_with_next_solver() {\n    let src = std::fs::read_to_string(\"src/lib.rs\").unwrap_or_default();\n    assert!(!(uses_generic_const_exprs(&src) && next_solver_active()),\n        \"generic_const_exprs cannot coexist with -Znext-solver\");\n}","typeGuard":null,"tryCatchPattern":"use std::panic::{catch_unwind, AssertUnwindSafe};\nlet r = catch_unwind(AssertUnwindSafe(|| cargo_build_with_features(&[\"generic_const_exprs\"])));\nif r.is_err() { eprintln!(\"disable -Znext-solver or remove generic_const_exprs\"); }","preventionTips":["Choose one: either `generic_const_exprs` (legacy solver) or `-Znext-solver` (no GCE). Never both.","Refactor const-generic arithmetic to compile-time evaluated `const fn` values that don't need `generic_const_exprs`.","Record the feature/solver matrix in CI: run the matrix once and fail fast if a disallowed combo is selected.","Document the choice in `Cargo.toml` metadata or a `rust-toolchain.toml` comment so contributors don't flip it blindly."],"tags":["rust","rustc","trait-solver","next-solver","const-generics","generic-const-exprs","unsupported-feature"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}