Skip to content

Commit

Permalink
Rollup merge of #118486 - RalfJung:add-feature, r=compiler-errors
Browse files Browse the repository at this point in the history
generic_const_exprs: suggest to add the feature, not use it

Usually our missing feature messages look something like
```
  = help: add `#![feature(inline_const)]` to the crate attributes to enable
```
However `generic_const_exprs` used a different verb. That's inconsistent and it also means playground won't add that nice hyperlink to add the feature automatically. So let's use the same verb as everywhere else.
  • Loading branch information
TaKO8Ki authored Dec 1, 2023
2 parents a030add + 1dbfe17 commit 8b6e9ca
Show file tree
Hide file tree
Showing 34 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ resolve_param_in_non_trivial_anon_const =
.label = cannot perform const operation using `{$name}`
resolve_param_in_non_trivial_anon_const_help =
use `#![feature(generic_const_exprs)]` to allow generic const expressions
add `#![feature(generic_const_exprs)]` to allow generic const expressions
resolve_param_in_ty_of_const_param =
the type of const parameters must not depend on other generic parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let _array: [u32; <A as Foo>::Y];
| ^ cannot perform const operation using `A`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | links: [u32; A::LINKS], // Shouldn't suggest bounds already there.
| ^^^^^^^^ cannot perform const operation using `A`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: aborting due to 1 previous error

46 changes: 23 additions & 23 deletions tests/ui/const-generics/const-arg-in-const-arg.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let _: [u8; foo::<T>()];
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:16:23
Expand All @@ -14,7 +14,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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:18:23
Expand All @@ -23,7 +23,7 @@ LL | let _: [u8; faz::<'a>(&())];
| ^^ cannot perform const operation using `'a`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:20:23
Expand All @@ -32,7 +32,7 @@ LL | let _: [u8; baz::<'a>(&())];
| ^^ cannot perform const operation using `'a`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:21:23
Expand All @@ -41,7 +41,7 @@ LL | let _: [u8; faz::<'b>(&())];
| ^^ cannot perform const operation using `'b`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:23:23
Expand All @@ -50,7 +50,7 @@ LL | let _: [u8; baz::<'b>(&())];
| ^^ cannot perform const operation using `'b`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:26:23
Expand All @@ -59,7 +59,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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:28:23
Expand All @@ -68,7 +68,7 @@ LL | let _ = [0; faz::<'a>(&())];
| ^^ cannot perform const operation using `'a`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:30:23
Expand All @@ -77,7 +77,7 @@ LL | let _ = [0; baz::<'a>(&())];
| ^^ cannot perform const operation using `'a`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:31:23
Expand All @@ -86,7 +86,7 @@ LL | let _ = [0; faz::<'b>(&())];
| ^^ cannot perform const operation using `'b`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:33:23
Expand All @@ -95,7 +95,7 @@ LL | let _ = [0; baz::<'b>(&())];
| ^^ cannot perform const operation using `'b`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:34:24
Expand All @@ -104,7 +104,7 @@ LL | let _: Foo<{ foo::<T>() }>;
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:35:24
Expand All @@ -113,7 +113,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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:37:24
Expand All @@ -122,7 +122,7 @@ LL | let _: Foo<{ faz::<'a>(&()) }>;
| ^^ cannot perform const operation using `'a`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:39:24
Expand All @@ -131,7 +131,7 @@ LL | let _: Foo<{ baz::<'a>(&()) }>;
| ^^ cannot perform const operation using `'a`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:40:24
Expand All @@ -140,7 +140,7 @@ LL | let _: Foo<{ faz::<'b>(&()) }>;
| ^^ cannot perform const operation using `'b`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:42:24
Expand All @@ -149,7 +149,7 @@ LL | let _: Foo<{ baz::<'b>(&()) }>;
| ^^ cannot perform const operation using `'b`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:43:27
Expand All @@ -158,7 +158,7 @@ LL | let _ = Foo::<{ foo::<T>() }>;
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:44:27
Expand All @@ -167,7 +167,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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:46:27
Expand All @@ -176,7 +176,7 @@ LL | let _ = Foo::<{ faz::<'a>(&()) }>;
| ^^ cannot perform const operation using `'a`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:48:27
Expand All @@ -185,7 +185,7 @@ LL | let _ = Foo::<{ baz::<'a>(&()) }>;
| ^^ cannot perform const operation using `'a`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:49:27
Expand All @@ -194,7 +194,7 @@ LL | let _ = Foo::<{ faz::<'b>(&()) }>;
| ^^ cannot perform const operation using `'b`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:51:27
Expand All @@ -203,7 +203,7 @@ LL | let _ = Foo::<{ baz::<'b>(&()) }>;
| ^^ cannot perform const operation using `'b`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error[E0747]: unresolved item provided when a constant was expected
--> $DIR/const-arg-in-const-arg.rs:16:23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | pad: [u8; is_zst::<T>()],
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/const-argument-if-length.rs:15:12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let _: &'a ();
| ^^ cannot perform const operation using `'a`
|
= note: lifetime parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Foo<const N: usize, const M: usize = { N + 1 }>;
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/complex-generic-default-expr.rs:9:62
Expand All @@ -14,7 +14,7 @@ LL | struct Bar<T, const TYPE_SIZE: usize = { std::mem::size_of::<T>() }>(T);
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: aborting due to 2 previous errors

8 changes: 4 additions & 4 deletions tests/ui/const-generics/early/macro_rules-braces.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/macro_rules-braces.rs:36:19
Expand All @@ -36,7 +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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/macro_rules-braces.rs:41:20
Expand All @@ -45,7 +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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/macro_rules-braces.rs:46:19
Expand All @@ -54,7 +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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: aborting due to 6 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/array-size-in-generic-struct-param.rs:23:15
Expand All @@ -14,7 +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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: `Config` is forbidden as the type of a const generic parameter
--> $DIR/array-size-in-generic-struct-param.rs:21:21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
--> $DIR/dependence_lint.rs:21:37
Expand All @@ -14,7 +14,7 @@ LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable,
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

warning: cannot use constants which depend on generic parameters in types
--> $DIR/dependence_lint.rs:10:9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +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`
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: aborting due to 1 previous error

Loading

0 comments on commit 8b6e9ca

Please sign in to comment.