Skip to content

The vec![..] macro can be used in pattern position with bad diagnostics #61933

Description

fn main() {
    match Some(vec![3]) {
        Some(vec![x]) => (),
        _ => (),
    }
}

Gives error message:

error: unexpected `(` after qualified path
 --> src/main.rs:3:14
  |
3 |         Some(vec![x]) => (),
  |              ^^^^^^^
  |              |
  |              unexpected `(` after qualified path
  |              in this macro invocation
  |
  = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

But this is clearly wrong as there is no ( in the span pointed to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-slice-patternsArea: Slice patterns, https://github.com/rust-lang/rust/issues/23121D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-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