Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed const_generics error help #80714

Merged
merged 2 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
),
)
.note("the only supported types are integers, `bool` and `char`")
.help("more complex types are supported with `#[feature(const_generics)]`")
.help("more complex types are supported with `#![feature(const_generics)]`")
.emit()
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LL | struct B<const CFG: Config> {
| ^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 3 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LL | fn bar<const X: (), 'a>(_: &'a ()) {
| ^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `()` is forbidden as the type of a const generic parameter
--> $DIR/const-param-before-other-params.rs:10:17
Expand All @@ -26,7 +26,7 @@ LL | fn foo<const X: (), T>(_: &T) {}
| ^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 4 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ LL | struct A<const N: &u8>;
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:15:15
Expand All @@ -44,7 +44,7 @@ LL | impl<const N: &u8> A<N> {
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:23:15
Expand All @@ -53,7 +53,7 @@ LL | impl<const N: &u8> B for A<N> {}
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:27:17
Expand All @@ -62,7 +62,7 @@ LL | fn bar<const N: &u8>() {}
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:18:21
Expand All @@ -71,7 +71,7 @@ LL | fn foo<const M: &u8>(&self) {}
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 10 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `[u8; _]` is forbidden as the type of a const generic parameter
--> $DIR/const-param-type-depends-on-const-param.rs:15:35
Expand All @@ -26,7 +26,7 @@ LL | pub struct SelfDependent<const N: [u8; N]>;
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 4 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/different_byref.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Const<const V: [usize; 1]> {}
| ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct B<const X: A>; // ok
| ^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `C` is forbidden as the type of a const generic parameter
--> $DIR/forbid-non-structural_match-types.rs:14:19
Expand All @@ -14,7 +14,7 @@ LL | struct D<const X: C>;
| ^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
--> $DIR/forbid-non-structural_match-types.rs:14:19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LL | trait Trait<const S: &'static str> {}
| ^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | trait Trait<const NAME: &'static str> {
| ^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn foo<const T: NoMatch>() -> bool {
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/issues/issue-62878.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 2 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn test<const T: &'static dyn A>() {
| ^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
--> $DIR/issue-63322-forbid-dyn.rs:9:18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Const<const V: [usize; 0]> {}
| ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Foo<const V: [usize; 0] > {}
| ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/issues/issue-71169.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
| ^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/issues/issue-73491.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn hoge<const IN: [u32; LEN]>() {}
| ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/const-generics/issues/issue-74101.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn test<const N: [u8; 1 + 2]>() {}
| ^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `[u8; _]` is forbidden as the type of a const generic parameter
--> $DIR/issue-74101.rs:9:21
Expand All @@ -14,7 +14,7 @@ LL | struct Foo<const N: [u8; 1 + 2]>;
| ^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/issues/issue-74255.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn ice_struct_fn<const I: IceEnum>() {}
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

10 changes: 5 additions & 5 deletions src/test/ui/const-generics/issues/issue-74950.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Outer<const I: Inner>;
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:17:23
Expand All @@ -14,7 +14,7 @@ LL | struct Outer<const I: Inner>;
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:17:23
Expand All @@ -23,7 +23,7 @@ LL | struct Outer<const I: Inner>;
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:17:23
Expand All @@ -32,7 +32,7 @@ LL | struct Outer<const I: Inner>;
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:17:23
Expand All @@ -41,7 +41,7 @@ LL | struct Outer<const I: Inner>;
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 5 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/issues/issue-75047.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Foo<const N: [u8; Bar::<u32>::value()]>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Foo<const N: [u8; 0]>;
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `()` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:6:21
Expand All @@ -14,7 +14,7 @@ LL | struct Bar<const N: ()>;
| ^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `No` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:11:21
Expand All @@ -23,7 +23,7 @@ LL | struct Fez<const N: No>;
| ^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:14:21
Expand All @@ -32,7 +32,7 @@ LL | struct Faz<const N: &'static u8>;
| ^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `!` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:17:21
Expand All @@ -41,7 +41,7 @@ LL | struct Fiz<const N: !>;
| ^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `()` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:20:19
Expand All @@ -50,7 +50,7 @@ LL | enum Goo<const N: ()> { A, B }
| ^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `()` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:23:20
Expand All @@ -59,7 +59,7 @@ LL | union Boo<const N: ()> { a: () }
| ^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 7 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn a<const X: &'static [u32]>() {}
| ^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Const<const P: &'static ()>;
| ^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/nested-type.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | | }]>;
| |__^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> $DIR/nested-type.rs:15:5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct ConstString<const T: &'static str>;
| ^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: `&'static [u8]` is forbidden as the type of a const generic parameter
--> $DIR/slice-const-param-mismatch.rs:9:28
Expand All @@ -14,7 +14,7 @@ LL | struct ConstBytes<const T: &'static [u8]>;
| ^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#[feature(const_generics)]`
= help: more complex types are supported with `#![feature(const_generics)]`

error: aborting due to 2 previous errors

Loading