Closed
Description
I ended up spending way too much time debugging the following error, since I was trying to port some C code to rust.
const ARR: [u8; 3] = {
1, 2, 3
}
Give the error:
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,`
--> src/lib.rs:2:6
|
2 | 1, 2, 3,
| ^ expected one of `.`, `;`, `?`, `}`, or an operator
error: aborting due to previous error
error: could not compile `playground`
The error message is very vague and hard to determine the actual error here.
Seeing as though some programming languages like Java and C use {}
for arrays, I think it'd make sense for the compiler to suggest using []
if the user is trying to create an array.
Activity
hkmatsumoto commentedon Aug 5, 2021
I suppose adding manual diagnostic somewhere around
rustc_parse::parse::parse_block_expr
will get the job done.@rustbot claim
Auto merge of rust-lang#87830 - hkmatsumoto:suggest-brackets-for-arra…