Next-gen Trait Solver does not implement Generic Const Expressions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
I was fluffing around with different generic stuff and ended up enabling the Next-gen solver, where I realized that it looked like Generic Const Expressions just don't work at all.
This code seems to work fine with the default trait solver, but when you enable the -Znext-solver flag, it throws a normalization error.
#![feature(generic_const_exprs)]
pub struct Vec<T, const N: usize>
where
[T; N * N]: Sized,
{
packed: [T; N * N],
}
I understand this is all very unstable stuff, but thought it was still probably slightly unintended behavior at the least.
Meta
rustc --version --verbose:
rustc 1.82.0-nightly (100fde524 2024-08-28)
binary: rustc
commit-hash: 100fde5246bf56f22fb5cc85374dd841296fce0e
commit-date: 2024-08-28
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0
Backtrace
error[E0284]: type annotations needed: cannot normalize `Vec<T, N>::packed::{constant#0}`
--> src/main.rs:6:13
|
6 | packed: [T; N * N],
| ^^^^^^^^^^ cannot normalize `Vec<T, N>::packed::{constant#0}`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure from the generic-const-expressions snippet in src/main.rs, first with the default solver and then with -Znext-solver. Read the compiler's trait-solver and normalization entry points to determine where the expression fails; done means the snippet no longer produces the reported normalization error under the next-generation solver.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100