diff options
| author | mendess <pedro.mendes.26@gmail.com> | 2020-11-24 09:35:08 +0000 |
|---|---|---|
| committer | mendess <pedro.mendes.26@gmail.com> | 2020-11-24 09:35:08 +0000 |
| commit | b7593e5070e71af5d43b29c84611a836b8d0fdcc (patch) | |
| tree | 6da2dabec7d89349673d1c284f284d29a6bb0b4d | |
| parent | d9a105fdd46c926ae606777a46dd90e5b838f92f (diff) | |
| download | rust-b7593e5070e71af5d43b29c84611a836b8d0fdcc.tar.gz rust-b7593e5070e71af5d43b29c84611a836b8d0fdcc.zip | |
Add note to use nightly when using expr in const generics
22 files changed, 41 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 67491b5bf7e..70ab59970d8 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -480,6 +480,7 @@ impl<'a> Resolver<'a> { "const parameters may only be used as standalone arguments, i.e. `{}`", name )); + err.note("use feature(const_generics) and feature(const_evaluatable_checked) to enable this"); } err diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr b/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr index cfaacf7a5be..ae3b593f9d3 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr @@ -5,6 +5,7 @@ LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]); | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/array-size-in-generic-struct-param.rs:20:15 @@ -13,6 +14,7 @@ LL | arr: [u8; CFG.arr_size], | ^^^ cannot perform const operation using `CFG` | = help: const parameters may only be used as standalone arguments, i.e. `CFG` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: `Config` is forbidden as the type of a const generic parameter --> $DIR/array-size-in-generic-struct-param.rs:18:21 diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr index 7dfe250b78e..9e3c07558f1 100644 --- a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr +++ b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr @@ -13,6 +13,7 @@ LL | let _: [u8; bar::<N>()]; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/const-arg-in-const-arg.rs:25:23 @@ -21,6 +22,7 @@ LL | let _ = [0; bar::<N>()]; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/const-arg-in-const-arg.rs:30:24 @@ -37,6 +39,7 @@ LL | let _: Foo<{ bar::<N>() }>; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/const-arg-in-const-arg.rs:36:27 @@ -53,6 +56,7 @@ LL | let _ = Foo::<{ bar::<N>() }>; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error[E0658]: a non-static lifetime is not allowed in a `const` --> $DIR/const-arg-in-const-arg.rs:16:23 diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr index 359c2d2a22f..8da75e953ff 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr @@ -5,6 +5,7 @@ LL | type Arr<const N: usize> = [u8; N - 1]; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to previous error diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr index 46485262cc4..91438ee1f65 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr @@ -5,6 +5,7 @@ LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default { | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/simple.rs:8:35 @@ -13,6 +14,7 @@ LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default { | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr index 981d993f589..dd2164ee45a 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr @@ -5,6 +5,7 @@ LL | type Arr<const N: usize> = [u8; N - 1]; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to previous error diff --git a/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr b/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr index 84449018e46..9d2524b6095 100644 --- a/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr +++ b/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr @@ -5,6 +5,7 @@ LL | fn bar<const N: usize>() -> [u32; foo(N)] { | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/generic-function-call-in-array-length.rs:12:13 @@ -13,6 +14,7 @@ LL | [0; foo(N)] | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr b/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr index d3f7143327e..5a0e72524fb 100644 --- a/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr +++ b/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr @@ -5,6 +5,7 @@ LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {} | ^ cannot perform const operation using `A` | = help: const parameters may only be used as standalone arguments, i.e. `A` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $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]) {} | ^ cannot perform const operation using `B` | = help: const parameters may only be used as standalone arguments, i.e. `B` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr b/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr index 526807f0a24..0ec673593d0 100644 --- a/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr +++ b/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr @@ -5,6 +5,7 @@ LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]); | ^^^^^ cannot perform const operation using `COUNT` | = help: const parameters may only be used as standalone arguments, i.e. `COUNT` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/issue-61522-array-len-succ.rs:12:30 @@ -13,6 +14,7 @@ LL | fn inner(&self) -> &[u8; COUNT + 1] { | ^^^^^ cannot perform const operation using `COUNT` | = help: const parameters may only be used as standalone arguments, i.e. `COUNT` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/issues/issue-61747.min.stderr b/src/test/ui/const-generics/issues/issue-61747.min.stderr index b176f9d1c75..1e4fdd885ec 100644 --- a/src/test/ui/const-generics/issues/issue-61747.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61747.min.stderr @@ -5,6 +5,7 @@ LL | fn successor() -> Const<{C + 1}> { | ^ cannot perform const operation using `C` | = help: const parameters may only be used as standalone arguments, i.e. `C` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-61935.min.stderr b/src/test/ui/const-generics/issues/issue-61935.min.stderr index 9e31466259f..cf1ff180935 100644 --- a/src/test/ui/const-generics/issues/issue-61935.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61935.min.stderr @@ -5,6 +5,7 @@ LL | Self:FooImpl<{N==0}> | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-62220.min.stderr b/src/test/ui/const-generics/issues/issue-62220.min.stderr index 3bd127ee74a..dd8fbfebd2f 100644 --- a/src/test/ui/const-generics/issues/issue-62220.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62220.min.stderr @@ -5,6 +5,7 @@ LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-62456.min.stderr b/src/test/ui/const-generics/issues/issue-62456.min.stderr index c73f62a4a07..ac11191b119 100644 --- a/src/test/ui/const-generics/issues/issue-62456.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62456.min.stderr @@ -5,6 +5,7 @@ LL | let _ = [0u64; N + 1]; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-66205.min.stderr b/src/test/ui/const-generics/issues/issue-66205.min.stderr index 282f72be6da..f3e3eb6c5a6 100644 --- a/src/test/ui/const-generics/issues/issue-66205.min.stderr +++ b/src/test/ui/const-generics/issues/issue-66205.min.stderr @@ -5,6 +5,7 @@ LL | fact::<{ N - 1 }>(); | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-68366.min.stderr b/src/test/ui/const-generics/issues/issue-68366.min.stderr index b900a0d096a..7dcb3ea1acb 100644 --- a/src/test/ui/const-generics/issues/issue-68366.min.stderr +++ b/src/test/ui/const-generics/issues/issue-68366.min.stderr @@ -5,6 +5,7 @@ LL | impl <const N: usize> Collatz<{Some(N)}> {} | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates --> $DIR/issue-68366.rs:12:13 diff --git a/src/test/ui/const-generics/issues/issue-68977.min.stderr b/src/test/ui/const-generics/issues/issue-68977.min.stderr index 7828d859394..67ca519de2c 100644 --- a/src/test/ui/const-generics/issues/issue-68977.min.stderr +++ b/src/test/ui/const-generics/issues/issue-68977.min.stderr @@ -5,6 +5,7 @@ LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; | ^^^^^^^^ cannot perform const operation using `INT_BITS` | = help: const parameters may only be used as standalone arguments, i.e. `INT_BITS` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/issue-68977.rs:29:28 @@ -13,6 +14,7 @@ LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; | ^^^^^^^^^ cannot perform const operation using `FRAC_BITS` | = help: const parameters may only be used as standalone arguments, i.e. `FRAC_BITS` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/issues/issue-72787.min.stderr b/src/test/ui/const-generics/issues/issue-72787.min.stderr index d960d9513b7..2a7672d0c89 100644 --- a/src/test/ui/const-generics/issues/issue-72787.min.stderr +++ b/src/test/ui/const-generics/issues/issue-72787.min.stderr @@ -5,6 +5,7 @@ LL | Condition<{ LHS <= RHS }>: True | ^^^ cannot perform const operation using `LHS` | = help: const parameters may only be used as standalone arguments, i.e. `LHS` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/issue-72787.rs:11:24 @@ -13,6 +14,7 @@ LL | Condition<{ LHS <= RHS }>: True | ^^^ cannot perform const operation using `RHS` | = help: const parameters may only be used as standalone arguments, i.e. `RHS` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/issue-72787.rs:26:25 @@ -21,6 +23,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^ cannot perform const operation using `I` | = help: const parameters may only be used as standalone arguments, i.e. `I` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/issue-72787.rs:26:36 @@ -29,6 +32,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^ cannot perform const operation using `J` | = help: const parameters may only be used as standalone arguments, i.e. `J` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error[E0283]: type annotations needed --> $DIR/issue-72787.rs:22:26 diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr index 9fec3eb946d..f7c4109e552 100644 --- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr +++ b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr @@ -5,6 +5,7 @@ LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue, | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr index c10db84ea6e..57514736121 100644 --- a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr +++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr @@ -13,6 +13,7 @@ LL | fn const_param<const N: usize>() -> [u8; N + 1] { | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/macro_rules-braces.min.stderr b/src/test/ui/const-generics/macro_rules-braces.min.stderr index c6425edc10f..b23053756d1 100644 --- a/src/test/ui/const-generics/macro_rules-braces.min.stderr +++ b/src/test/ui/const-generics/macro_rules-braces.min.stderr @@ -27,6 +27,7 @@ LL | let _: foo!({{ N }}); | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/macro_rules-braces.rs:41:19 @@ -35,6 +36,7 @@ LL | let _: bar!({ N }); | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/macro_rules-braces.rs:46:20 @@ -43,6 +45,7 @@ LL | let _: baz!({{ N }}); | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/macro_rules-braces.rs:51:19 @@ -51,6 +54,7 @@ LL | let _: biz!({ N }); | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to 6 previous errors diff --git a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr index a8de987e167..d8debd2b930 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr +++ b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr @@ -5,6 +5,7 @@ LL | struct Break0<const N: usize>([u8; { N + 1 }]); | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/complex-expression.rs:14:40 @@ -13,6 +14,7 @@ LL | struct Break1<const N: usize>([u8; { { N } }]); | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/complex-expression.rs:18:17 @@ -21,6 +23,7 @@ LL | let _: [u8; N + 1]; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/complex-expression.rs:23:17 @@ -29,6 +32,7 @@ LL | let _ = [0; N + 1]; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/complex-expression.rs:27:45 diff --git a/src/test/ui/const-generics/wf-misc.min.stderr b/src/test/ui/const-generics/wf-misc.min.stderr index 935f12dd2c3..296b1c15cf0 100644 --- a/src/test/ui/const-generics/wf-misc.min.stderr +++ b/src/test/ui/const-generics/wf-misc.min.stderr @@ -5,6 +5,7 @@ LL | let _: [u8; N + 1]; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: generic parameters may not be used in const operations --> $DIR/wf-misc.rs:17:21 @@ -13,6 +14,7 @@ LL | let _: Const::<{N + 1}>; | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` + = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this error: aborting due to 2 previous errors |
