generic_const_exprs and inline_const interact poorly.
Open
Nobody has claimed this yet.
C-bug
F-generic_const_exprs
F-inline_const
P-low
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
On current nightly, this code works:
#![feature(inline_const)]
fn foo<const N: usize>() {
const {
assert!(N > 0);
}
}
fn main() {
foo::<4>();
}
However this code fails to compile if generic_const_exprs is enabled, by just adding #![feature(generic_const_exprs)] at the top of the file:
error: overly complex generic constant
--> t.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
error: aborting due to 1 previous error; 1 warning emitted
Which is clearly broken? generic_const_exprs should probably not try to dig into that expression to begin with.
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
Start by reproducing the minimal examples from the issue on nightly, comparing compilation with and without generic_const_exprs. Trace the compiler handling of the inline const block in a generic context; done means the valid example no longer produces the overly complex generic constant error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100