Skip to content

Next-gen Trait Solver does not implement Generic Const Expressions #129766

Open
@GamingLiamStudios

Description

@GamingLiamStudios

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}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)requires-incomplete-featuresThis issue requires the use of incomplete features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions