Skip to content

Commit 102f7a8

Browse files
committed
Make sure const params with type params don't cause errors without a feature gate
1 parent 976b3d1 commit 102f7a8

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use std::marker::PhantomData;
2+
3+
struct B<T, const N: T>(PhantomData<[T; N]>); //~ ERROR const generics are unstable
4+
//~^ ERROR const parameters cannot depend on type parameters
5+
6+
fn main() {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0671]: const parameters cannot depend on type parameters
2+
--> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:22
3+
|
4+
LL | struct B<T, const N: T>(PhantomData<[T; N]>);
5+
| ^ const parameter depends on type parameter
6+
7+
error[E0658]: const generics are unstable
8+
--> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:19
9+
|
10+
LL | struct B<T, const N: T>(PhantomData<[T; N]>);
11+
| ^
12+
|
13+
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
14+
= help: add #![feature(const_generics)] to the crate attributes to enable
15+
16+
error: aborting due to 2 previous errors
17+
18+
Some errors have detailed explanations: E0658, E0671.
19+
For more information about an error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)