2022-03-24 23:34:57 -05:00
|
|
|
error: this is a block expression, not an array
|
Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
--> src/lib.rs:1:22
|
1 | const FOO: [u8; 3] = {
| ______________________^
2 | | 1, 2, 3
3 | | };
| |_^
|
= note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
|
1 | const FOO: [u8; 3] = [
2 | 1, 2, 3
3 | ];
|
```
Fix #87672
2021-08-06 14:34:29 -05:00
|
|
|
--> $DIR/issue-87830-try-brackets-for-arrays.rs:3:22
|
|
|
|
|
|
|
|
|
LL | const FOO: [u8; 3] = {
|
|
|
|
| ______________________^
|
2022-03-24 23:34:57 -05:00
|
|
|
LL | |
|
Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
--> src/lib.rs:1:22
|
1 | const FOO: [u8; 3] = {
| ______________________^
2 | | 1, 2, 3
3 | | };
| |_^
|
= note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
|
1 | const FOO: [u8; 3] = [
2 | 1, 2, 3
3 | ];
|
```
Fix #87672
2021-08-06 14:34:29 -05:00
|
|
|
LL | | 1, 2, 3
|
|
|
|
LL | | };
|
|
|
|
| |_^
|
|
|
|
|
|
2022-03-24 23:34:57 -05:00
|
|
|
help: to make an array, use square brackets instead of curly braces
|
Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
--> src/lib.rs:1:22
|
1 | const FOO: [u8; 3] = {
| ______________________^
2 | | 1, 2, 3
3 | | };
| |_^
|
= note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
|
1 | const FOO: [u8; 3] = [
2 | 1, 2, 3
3 | ];
|
```
Fix #87672
2021-08-06 14:34:29 -05:00
|
|
|
|
|
|
|
|
LL ~ const FOO: [u8; 3] = [
|
2022-03-24 23:34:57 -05:00
|
|
|
LL |
|
Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
--> src/lib.rs:1:22
|
1 | const FOO: [u8; 3] = {
| ______________________^
2 | | 1, 2, 3
3 | | };
| |_^
|
= note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
|
1 | const FOO: [u8; 3] = [
2 | 1, 2, 3
3 | ];
|
```
Fix #87672
2021-08-06 14:34:29 -05:00
|
|
|
LL | 1, 2, 3
|
|
|
|
LL ~ ];
|
|
|
|
|
|
|
|
|
|
2022-03-24 23:34:57 -05:00
|
|
|
error: this is a block expression, not an array
|
|
|
|
--> $DIR/issue-87830-try-brackets-for-arrays.rs:8:24
|
Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
--> src/lib.rs:1:22
|
1 | const FOO: [u8; 3] = {
| ______________________^
2 | | 1, 2, 3
3 | | };
| |_^
|
= note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
|
1 | const FOO: [u8; 3] = [
2 | 1, 2, 3
3 | ];
|
```
Fix #87672
2021-08-06 14:34:29 -05:00
|
|
|
|
|
|
|
|
LL | const BAR: [&str; 3] = {"one", "two", "three"};
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2022-03-24 23:34:57 -05:00
|
|
|
help: to make an array, use square brackets instead of curly braces
|
Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
--> src/lib.rs:1:22
|
1 | const FOO: [u8; 3] = {
| ______________________^
2 | | 1, 2, 3
3 | | };
| |_^
|
= note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
|
1 | const FOO: [u8; 3] = [
2 | 1, 2, 3
3 | ];
|
```
Fix #87672
2021-08-06 14:34:29 -05:00
|
|
|
|
|
|
|
|
LL | const BAR: [&str; 3] = ["one", "two", "three"];
|
|
|
|
| ~ ~
|
|
|
|
|
2022-03-24 23:34:57 -05:00
|
|
|
error: this is a block expression, not an array
|
|
|
|
--> $DIR/issue-87830-try-brackets-for-arrays.rs:12:5
|
Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
--> src/lib.rs:1:22
|
1 | const FOO: [u8; 3] = {
| ______________________^
2 | | 1, 2, 3
3 | | };
| |_^
|
= note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
|
1 | const FOO: [u8; 3] = [
2 | 1, 2, 3
3 | ];
|
```
Fix #87672
2021-08-06 14:34:29 -05:00
|
|
|
|
|
|
|
|
LL | {1, 2, 3};
|
|
|
|
| ^^^^^^^^^
|
|
|
|
|
|
2022-03-24 23:34:57 -05:00
|
|
|
help: to make an array, use square brackets instead of curly braces
|
Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
--> src/lib.rs:1:22
|
1 | const FOO: [u8; 3] = {
| ______________________^
2 | | 1, 2, 3
3 | | };
| |_^
|
= note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
|
1 | const FOO: [u8; 3] = [
2 | 1, 2, 3
3 | ];
|
```
Fix #87672
2021-08-06 14:34:29 -05:00
|
|
|
|
|
|
|
|
LL | [1, 2, 3];
|
|
|
|
| ~ ~
|
|
|
|
|
|
|
|
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,`
|
2022-03-24 23:34:57 -05:00
|
|
|
--> $DIR/issue-87830-try-brackets-for-arrays.rs:17:6
|
Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
--> src/lib.rs:1:22
|
1 | const FOO: [u8; 3] = {
| ______________________^
2 | | 1, 2, 3
3 | | };
| |_^
|
= note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
|
1 | const FOO: [u8; 3] = [
2 | 1, 2, 3
3 | ];
|
```
Fix #87672
2021-08-06 14:34:29 -05:00
|
|
|
|
|
|
|
|
LL | 1, 2, 3
|
|
|
|
| ^ expected one of `.`, `;`, `?`, `}`, or an operator
|
|
|
|
|
|
|
|
error: aborting due to 4 previous errors
|
|
|
|
|