Invalid help suggestion when vec
macro incorrectly used without !
#101490
Open
Description
Given the following code: link
fn main() {
let _x = vec[1, 2, 3];
}
The current output is:
Compiling playground v0.0.1 (/playground)
error: expected `;`, found `[`
--> src/main.rs:2:17
|
2 | let _x = vec[1, 2, 3];
| ^
|
help: consider adding `;` here
|
2 | let _x = vec;[1, 2, 3];
| +
error: could not compile `playground` due to previous error
Just for some context this is the current error message for the stable and beta versions:
Compiling playground v0.0.1 (/playground)
error: expected one of `.`, `?`, `]`, or an operator, found `,`
--> src/main.rs:2:19
|
2 | let _x = vec[1, 2, 3];
| ^ expected one of `.`, `?`, `]`, or an operator
error: could not compile `playground` due to previous error
Which is also not ideal as for the other std macros AFAIK (only checked a few), incorrect usage (i.e. without the !
) will lead to a help suggestion informing the user to include a !
to invoke a macro (e.g. print
, println
).
Hence, the ideal output is to suggest adding the !
when invoking the vec
macro incorrectly as with other macros.
@rustbot label +regression-from-stable-to-nightly +D-invalid-suggestion
May need a bisect.