Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b7593e5

Browse files
committed
Add note to use nightly when using expr in const generics
1 parent d9a105f commit b7593e5

22 files changed

+41
-0
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ impl<'a> Resolver<'a> {
480480
"const parameters may only be used as standalone arguments, i.e. `{}`",
481481
name
482482
));
483+
err.note("use feature(const_generics) and feature(const_evaluatable_checked) to enable this");
483484
}
484485

485486
err

src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
55
| ^ cannot perform const operation using `N`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `N`
8+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
89

910
error: generic parameters may not be used in const operations
1011
--> $DIR/array-size-in-generic-struct-param.rs:20:15
@@ -13,6 +14,7 @@ LL | arr: [u8; CFG.arr_size],
1314
| ^^^ cannot perform const operation using `CFG`
1415
|
1516
= help: const parameters may only be used as standalone arguments, i.e. `CFG`
17+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
1618

1719
error: `Config` is forbidden as the type of a const generic parameter
1820
--> $DIR/array-size-in-generic-struct-param.rs:18:21

src/test/ui/const-generics/const-arg-in-const-arg.min.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ LL | let _: [u8; bar::<N>()];
1313
| ^ cannot perform const operation using `N`
1414
|
1515
= help: const parameters may only be used as standalone arguments, i.e. `N`
16+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
1617

1718
error: generic parameters may not be used in const operations
1819
--> $DIR/const-arg-in-const-arg.rs:25:23
@@ -21,6 +22,7 @@ LL | let _ = [0; bar::<N>()];
2122
| ^ cannot perform const operation using `N`
2223
|
2324
= help: const parameters may only be used as standalone arguments, i.e. `N`
25+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
2426

2527
error: generic parameters may not be used in const operations
2628
--> $DIR/const-arg-in-const-arg.rs:30:24
@@ -37,6 +39,7 @@ LL | let _: Foo<{ bar::<N>() }>;
3739
| ^ cannot perform const operation using `N`
3840
|
3941
= help: const parameters may only be used as standalone arguments, i.e. `N`
42+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
4043

4144
error: generic parameters may not be used in const operations
4245
--> $DIR/const-arg-in-const-arg.rs:36:27
@@ -53,6 +56,7 @@ LL | let _ = Foo::<{ bar::<N>() }>;
5356
| ^ cannot perform const operation using `N`
5457
|
5558
= help: const parameters may only be used as standalone arguments, i.e. `N`
59+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
5660

5761
error[E0658]: a non-static lifetime is not allowed in a `const`
5862
--> $DIR/const-arg-in-const-arg.rs:16:23

src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | type Arr<const N: usize> = [u8; N - 1];
55
| ^ cannot perform const operation using `N`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `N`
8+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
89

910
error: aborting due to previous error
1011

src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
55
| ^ cannot perform const operation using `N`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `N`
8+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
89

910
error: generic parameters may not be used in const operations
1011
--> $DIR/simple.rs:8:35
@@ -13,6 +14,7 @@ LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
1314
| ^ cannot perform const operation using `N`
1415
|
1516
= help: const parameters may only be used as standalone arguments, i.e. `N`
17+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
1618

1719
error: aborting due to 2 previous errors
1820

src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | type Arr<const N: usize> = [u8; N - 1];
55
| ^ cannot perform const operation using `N`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `N`
8+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
89

910
error: aborting due to previous error
1011

src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | fn bar<const N: usize>() -> [u32; foo(N)] {
55
| ^ cannot perform const operation using `N`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `N`
8+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
89

910
error: generic parameters may not be used in const operations
1011
--> $DIR/generic-function-call-in-array-length.rs:12:13
@@ -13,6 +14,7 @@ LL | [0; foo(N)]
1314
| ^ cannot perform const operation using `N`
1415
|
1516
= help: const parameters may only be used as standalone arguments, i.e. `N`
17+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
1618

1719
error: aborting due to 2 previous errors
1820

src/test/ui/const-generics/generic-sum-in-array-length.min.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
55
| ^ cannot perform const operation using `A`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `A`
8+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
89

910
error: generic parameters may not be used in const operations
1011
--> $DIR/generic-sum-in-array-length.rs:7:57
@@ -13,6 +14,7 @@ LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
1314
| ^ cannot perform const operation using `B`
1415
|
1516
= help: const parameters may only be used as standalone arguments, i.e. `B`
17+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
1618

1719
error: aborting due to 2 previous errors
1820

src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
55
| ^^^^^ cannot perform const operation using `COUNT`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `COUNT`
8+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
89

910
error: generic parameters may not be used in const operations
1011
--> $DIR/issue-61522-array-len-succ.rs:12:30
@@ -13,6 +14,7 @@ LL | fn inner(&self) -> &[u8; COUNT + 1] {
1314
| ^^^^^ cannot perform const operation using `COUNT`
1415
|
1516
= help: const parameters may only be used as standalone arguments, i.e. `COUNT`
17+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
1618

1719
error: aborting due to 2 previous errors
1820

src/test/ui/const-generics/issues/issue-61747.min.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | fn successor() -> Const<{C + 1}> {
55
| ^ cannot perform const operation using `C`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `C`
8+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
89

910
error: aborting due to previous error
1011

0 commit comments

Comments
 (0)