Rollup merge of #89317 - JulianKnodt:precise_errors, r=BoxyUwU

Move generic error message to separate branches

This decomposes an error message in generic constants into more specific branches, for better
readability.

r? ``@lcnr``
This commit is contained in:
Manish Goregaokar 2021-10-05 12:52:44 -07:00 committed by GitHub
commit 0352a2820d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 54 deletions

View file

@ -10,9 +10,10 @@ error: overly complex generic constant
--> $DIR/array-size-in-generic-struct-param.rs:19:15
|
LL | arr: [u8; CFG.arr_size],
| ^^^^^^^^^^^^ unsupported operation in generic constant, this may be supported in the future
| ^^^^^^^^^^^^ field access is not supported in generic constant
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: aborting due to 2 previous errors

View file

@ -4,9 +4,10 @@ error: overly complex generic constant
LL | fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
| ^^^^-------^^
| |
| unsupported operation in generic constant, this may be supported in the future
| dereferencing is not supported in generic constants
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: aborting due to previous error

View file

@ -2,17 +2,19 @@ error: overly complex generic constant
--> $DIR/let-bindings.rs:6:68
|
LL | fn test<const N: usize>() -> [u8; { let x = N; N + 1 }] where [u8; { let x = N; N + 1 }]: Default {
| ^^^^^^^^^^^^^^^^^^^^ unsupported operation in generic constant, this may be supported in the future
| ^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constant
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: overly complex generic constant
--> $DIR/let-bindings.rs:6:35
|
LL | fn test<const N: usize>() -> [u8; { let x = N; N + 1 }] where [u8; { let x = N; N + 1 }]: Default {
| ^^^^^^^^^^^^^^^^^^^^ unsupported operation in generic constant, this may be supported in the future
| ^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constant
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: aborting due to 2 previous errors

View file

@ -2,25 +2,28 @@ error: overly complex generic constant
--> $DIR/unused_expr.rs:4:34
|
LL | fn add<const N: usize>() -> [u8; { N + 1; 5 }] {
| ^^^^^^^^^^^^ unsupported operation in generic constant, this may be supported in the future
| ^^^^^^^^^^^^ blocks are not supported in generic constant
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: overly complex generic constant
--> $DIR/unused_expr.rs:9:34
|
LL | fn div<const N: usize>() -> [u8; { N / 1; 5 }] {
| ^^^^^^^^^^^^ unsupported operation in generic constant, this may be supported in the future
| ^^^^^^^^^^^^ blocks are not supported in generic constant
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: overly complex generic constant
--> $DIR/unused_expr.rs:16:38
|
LL | fn fn_call<const N: usize>() -> [u8; { foo(N); 5 }] {
| ^^^^^^^^^^^^^ unsupported operation in generic constant, this may be supported in the future
| ^^^^^^^^^^^^^ blocks are not supported in generic constant
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: aborting due to 3 previous errors

View file

@ -4,7 +4,7 @@ error: overly complex generic constant
LL | inner: [(); { [|_: &T| {}; 0].len() }],
| ^^---------------------^^
| |
| unsupported operation in generic constant
| pointer casts are not allowed in generic constants
|
= help: consider moving this anonymous constant into a `const` function

View file

@ -8,9 +8,10 @@ LL | | let x: Option<Box<Self>> = None;
LL | |
LL | | 0
LL | | }],
| |_____^ unsupported operation in generic constant, this may be supported in the future
| |_____^ blocks are not supported in generic constant
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: aborting due to previous error