-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[Regression] New depends on a generic parameter error #72979
Copy link
Copy link
Closed
Description
This used to work up to the penultimate Nightly version:
#![feature(const_generics)]
#![allow(incomplete_features)]
struct Foo<const N: usize> {
bits: [u32; N]
}
const fn spam(m: usize) -> usize {
m / 2
}
struct Bar<const M: usize> {
this: Foo<{ spam(M) }>,
}
fn main() {}Today it doesn't compile:
rustc 1.45.0-nightly (56daaf669 2020-06-03)
binary: rustc
commit-hash: 56daaf669ebc3d5083db5cded719f780dc31104e
commit-date: 2020-06-03
host: x86_64-pc-windows-gnu
release: 1.45.0-nightly
LLVM version: 10.0
Now it gives:
error: constant expression depends on a generic parameter
--> ...\test.rs:13:5
|
13 | this: Foo<{ spam(M) }>,
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes
error: aborting due to previous error
(This error reduces the usefulness of const generics for me).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.