Skip to content

Commit af978e3

Browse files
committed
Requested changes
1 parent b7593e5 commit af978e3

30 files changed

+59
-41
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ 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");
484483
}
484+
err.note("use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions");
485485

486486
err
487487
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: generic parameters may not be used in const operations
1111
--> $DIR/array-size-in-generic-struct-param.rs:20:15
@@ -14,7 +14,7 @@ LL | arr: [u8; CFG.arr_size],
1414
| ^^^ cannot perform const operation using `CFG`
1515
|
1616
= 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
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1818

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

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let _: [u8; foo::<T>()];
55
| ^ cannot perform const operation using `T`
66
|
77
= note: type parameters may not be used in const expressions
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
89

910
error: generic parameters may not be used in const operations
1011
--> $DIR/const-arg-in-const-arg.rs:15:23
@@ -13,7 +14,7 @@ LL | let _: [u8; bar::<N>()];
1314
| ^ cannot perform const operation using `N`
1415
|
1516
= 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
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1718

1819
error: generic parameters may not be used in const operations
1920
--> $DIR/const-arg-in-const-arg.rs:25:23
@@ -22,7 +23,7 @@ LL | let _ = [0; bar::<N>()];
2223
| ^ cannot perform const operation using `N`
2324
|
2425
= 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
26+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
2627

2728
error: generic parameters may not be used in const operations
2829
--> $DIR/const-arg-in-const-arg.rs:30:24
@@ -31,6 +32,7 @@ LL | let _: Foo<{ foo::<T>() }>;
3132
| ^ cannot perform const operation using `T`
3233
|
3334
= note: type parameters may not be used in const expressions
35+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
3436

3537
error: generic parameters may not be used in const operations
3638
--> $DIR/const-arg-in-const-arg.rs:31:24
@@ -39,7 +41,7 @@ LL | let _: Foo<{ bar::<N>() }>;
3941
| ^ cannot perform const operation using `N`
4042
|
4143
= 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
44+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
4345

4446
error: generic parameters may not be used in const operations
4547
--> $DIR/const-arg-in-const-arg.rs:36:27
@@ -48,6 +50,7 @@ LL | let _ = Foo::<{ foo::<T>() }>;
4850
| ^ cannot perform const operation using `T`
4951
|
5052
= note: type parameters may not be used in const expressions
53+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
5154

5255
error: generic parameters may not be used in const operations
5356
--> $DIR/const-arg-in-const-arg.rs:37:27
@@ -56,7 +59,7 @@ LL | let _ = Foo::<{ bar::<N>() }>;
5659
| ^ cannot perform const operation using `N`
5760
|
5861
= 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
62+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
6063

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

src/test/ui/const-generics/const-argument-if-length.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | pad: [u8; is_zst::<T>()],
55
| ^ cannot perform const operation using `T`
66
|
77
= note: type parameters may not be used in const expressions
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
89

910
error[E0277]: the size for values of type `T` cannot be known at compilation time
1011
--> $DIR/const-argument-if-length.rs:17:12

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: aborting due to previous error
1111

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: generic parameters may not be used in const operations
1111
--> $DIR/simple.rs:8:35
@@ -14,7 +14,7 @@ LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
1414
| ^ cannot perform const operation using `N`
1515
|
1616
= 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
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1818

1919
error: aborting due to 2 previous errors
2020

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: aborting due to previous error
1111

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: generic parameters may not be used in const operations
1111
--> $DIR/generic-function-call-in-array-length.rs:12:13
@@ -14,7 +14,7 @@ LL | [0; foo(N)]
1414
| ^ cannot perform const operation using `N`
1515
|
1616
= 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
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1818

1919
error: aborting due to 2 previous errors
2020

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: generic parameters may not be used in const operations
1111
--> $DIR/generic-sum-in-array-length.rs:7:57
@@ -14,7 +14,7 @@ LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
1414
| ^ cannot perform const operation using `B`
1515
|
1616
= 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
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1818

1919
error: aborting due to 2 previous errors
2020

src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | T: Trait<{std::intrinsics::type_name::<T>()}>
55
| ^ cannot perform const operation using `T`
66
|
77
= note: type parameters may not be used in const expressions
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
89

910
error: `&'static str` is forbidden as the type of a const generic parameter
1011
--> $DIR/intrinsics-type_name-as-const-argument.rs:10:22

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: generic parameters may not be used in const operations
1111
--> $DIR/issue-61522-array-len-succ.rs:12:30
@@ -14,7 +14,7 @@ LL | fn inner(&self) -> &[u8; COUNT + 1] {
1414
| ^^^^^ cannot perform const operation using `COUNT`
1515
|
1616
= 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
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1818

1919
error: aborting due to 2 previous errors
2020

src/test/ui/const-generics/issue-67375.min.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | inner: [(); { [|_: &T| {}; 0].len() }],
55
| ^ cannot perform const operation using `T`
66
|
77
= note: type parameters may not be used in const expressions
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
89

910
error[E0392]: parameter `T` is never used
1011
--> $DIR/issue-67375.rs:7:12

src/test/ui/const-generics/issue-67945-1.min.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let x: S = MaybeUninit::uninit();
55
| ^ cannot perform const operation using `S`
66
|
77
= note: type parameters may not be used in const expressions
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
89

910
error: generic parameters may not be used in const operations
1011
--> $DIR/issue-67945-1.rs:17:45
@@ -13,6 +14,7 @@ LL | let b = &*(&x as *const _ as *const S);
1314
| ^ cannot perform const operation using `S`
1415
|
1516
= note: type parameters may not be used in const expressions
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1618

1719
error[E0392]: parameter `S` is never used
1820
--> $DIR/issue-67945-1.rs:11:12

src/test/ui/const-generics/issue-67945-2.min.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let x: S = MaybeUninit::uninit();
55
| ^ cannot perform const operation using `S`
66
|
77
= note: type parameters may not be used in const expressions
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
89

910
error: generic parameters may not be used in const operations
1011
--> $DIR/issue-67945-2.rs:15:45
@@ -13,6 +14,7 @@ LL | let b = &*(&x as *const _ as *const S);
1314
| ^ cannot perform const operation using `S`
1415
|
1516
= note: type parameters may not be used in const expressions
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1618

1719
error[E0392]: parameter `S` is never used
1820
--> $DIR/issue-67945-2.rs:9:12

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: aborting due to previous error
1111

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: aborting due to previous error
1111

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: aborting due to previous error
1111

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: aborting due to previous error
1111

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

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
55
| ^^^^^^ cannot perform const operation using `T`
66
|
77
= note: type parameters may not be used in const expressions
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
89

910
error: generic parameters may not be used in const operations
1011
--> $DIR/issue-64494.rs:19:38
@@ -13,6 +14,7 @@ LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
1314
| ^^^^^^ cannot perform const operation using `T`
1415
|
1516
= note: type parameters may not be used in const expressions
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1618

1719
error[E0119]: conflicting implementations of trait `MyTrait`:
1820
--> $DIR/issue-64494.rs:19:1

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: aborting due to previous error
1111

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
1111
--> $DIR/issue-68366.rs:12:13

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +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
8+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
99

1010
error: generic parameters may not be used in const operations
1111
--> $DIR/issue-68977.rs:29:28
@@ -14,7 +14,7 @@ LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
1414
| ^^^^^^^^^ cannot perform const operation using `FRAC_BITS`
1515
|
1616
= 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
17+
= note: use #![feature(const_generics)] and #![feature(const_evaluatable_checked)] to allow generic const expressions
1818

1919
error: aborting due to 2 previous errors
2020

0 commit comments

Comments
 (0)