Skip to content

Invalid help suggestion when vec macro incorrectly used without ! #101490

Open
@Rageking8

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.

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The parsing of Rust source code to an ASTA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyD-papercutDiagnostics: An error or lint that needs small tweaks.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions