-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)Inline constants (aka: const blocks, const expressions, anonymous constants)P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
#![feature(generic_const_exprs)]
#![feature(inline_const)]
fn foo<const N: u32>() {
const {
assert!(N != 0);
}
}
I expected to see this happen: it compiles
Instead, this happened: it errors:
error: overly complex generic constant
--> src/lib.rs:5:11
|
5 | const {
| ___________^
6 | | assert!(N != 0);
7 | | }
| |_____^ blocks are not supported in generic constants
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
Removing the generic_const_exprs
feature allows the const block to compile
Meta
rustc --version --verbose
:
rustc 1.74.0-nightly (ca62d2c44 2023-09-30)
binary: rustc
commit-hash: ca62d2c445628587660ae48013f460b08b1f5552
commit-date: 2023-09-30
host: x86_64-apple-darwin
release: 1.74.0-nightly
LLVM version: 17.0.2
Backtrace
<backtrace>
zroug
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)Inline constants (aka: const blocks, const expressions, anonymous constants)P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.