Skip to content

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

+1
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

+2
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

+4
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

+1
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

+2
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

+1
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

+2
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

+2
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

+2
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

+1
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

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

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | Self:FooImpl<{N==0}>
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/issues/issue-62220.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { 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/issues/issue-62456.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let _ = [0u64; 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/issues/issue-66205.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | fact::<{ 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/issues/issue-68366.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | impl <const N: usize> Collatz<{Some(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[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
1011
--> $DIR/issue-68366.rs:12:13

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

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
55
| ^^^^^^^^ cannot perform const operation using `INT_BITS`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `INT_BITS`
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-68977.rs:29:28
@@ -13,6 +14,7 @@ LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
1314
| ^^^^^^^^^ cannot perform const operation using `FRAC_BITS`
1415
|
1516
= help: const parameters may only be used as standalone arguments, i.e. `FRAC_BITS`
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-72787.min.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | Condition<{ LHS <= RHS }>: True
55
| ^^^ cannot perform const operation using `LHS`
66
|
77
= help: const parameters may only be used as standalone arguments, i.e. `LHS`
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-72787.rs:11:24
@@ -13,6 +14,7 @@ LL | Condition<{ LHS <= RHS }>: True
1314
| ^^^ cannot perform const operation using `RHS`
1415
|
1516
= help: const parameters may only be used as standalone arguments, i.e. `RHS`
17+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
1618

1719
error: generic parameters may not be used in const operations
1820
--> $DIR/issue-72787.rs:26:25
@@ -21,6 +23,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
2123
| ^ cannot perform const operation using `I`
2224
|
2325
= help: const parameters may only be used as standalone arguments, i.e. `I`
26+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
2427

2528
error: generic parameters may not be used in const operations
2629
--> $DIR/issue-72787.rs:26:36
@@ -29,6 +32,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
2932
| ^ cannot perform const operation using `J`
3033
|
3134
= help: const parameters may only be used as standalone arguments, i.e. `J`
35+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
3236

3337
error[E0283]: type annotations needed
3438
--> $DIR/issue-72787.rs:22:26

src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue,
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/issues/issue-76701-ty-param-in-const.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ LL | fn const_param<const N: usize>() -> [u8; N + 1] {
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: aborting due to 2 previous errors
1819

src/test/ui/const-generics/macro_rules-braces.min.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ LL | let _: foo!({{ N }});
2727
| ^ cannot perform const operation using `N`
2828
|
2929
= help: const parameters may only be used as standalone arguments, i.e. `N`
30+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
3031

3132
error: generic parameters may not be used in const operations
3233
--> $DIR/macro_rules-braces.rs:41:19
@@ -35,6 +36,7 @@ LL | let _: bar!({ N });
3536
| ^ cannot perform const operation using `N`
3637
|
3738
= help: const parameters may only be used as standalone arguments, i.e. `N`
39+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
3840

3941
error: generic parameters may not be used in const operations
4042
--> $DIR/macro_rules-braces.rs:46:20
@@ -43,6 +45,7 @@ LL | let _: baz!({{ N }});
4345
| ^ cannot perform const operation using `N`
4446
|
4547
= help: const parameters may only be used as standalone arguments, i.e. `N`
48+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
4649

4750
error: generic parameters may not be used in const operations
4851
--> $DIR/macro_rules-braces.rs:51:19
@@ -51,6 +54,7 @@ LL | let _: biz!({ N });
5154
| ^ cannot perform const operation using `N`
5255
|
5356
= help: const parameters may only be used as standalone arguments, i.e. `N`
57+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
5458

5559
error: aborting due to 6 previous errors
5660

src/test/ui/const-generics/min_const_generics/complex-expression.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | struct Break0<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: generic parameters may not be used in const operations
1011
--> $DIR/complex-expression.rs:14:40
@@ -13,6 +14,7 @@ LL | struct Break1<const N: usize>([u8; { { 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: generic parameters may not be used in const operations
1820
--> $DIR/complex-expression.rs:18:17
@@ -21,6 +23,7 @@ LL | let _: [u8; N + 1];
2123
| ^ cannot perform const operation using `N`
2224
|
2325
= help: const parameters may only be used as standalone arguments, i.e. `N`
26+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
2427

2528
error: generic parameters may not be used in const operations
2629
--> $DIR/complex-expression.rs:23:17
@@ -29,6 +32,7 @@ LL | let _ = [0; N + 1];
2932
| ^ cannot perform const operation using `N`
3033
|
3134
= help: const parameters may only be used as standalone arguments, i.e. `N`
35+
= note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this
3236

3337
error: generic parameters may not be used in const operations
3438
--> $DIR/complex-expression.rs:27:45

src/test/ui/const-generics/wf-misc.min.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let _: [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: generic parameters may not be used in const operations
1011
--> $DIR/wf-misc.rs:17:21
@@ -13,6 +14,7 @@ LL | let _: Const::<{N + 1}>;
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

0 commit comments

Comments
 (0)