Skip to content

matches! problem with edition 2021 #84429

Closed
@leonardo-m

Description

@leonardo-m

If I compile this:

fn main() {
    let _b = matches!(b'3', b'0' ..= b'9');
}

With:

rustc 1.53.0-nightly (b84932674 2021-04-21)
binary: rustc
commit-hash: b849326744a8eec939e592f0ab13bff85cc865d3
commit-date: 2021-04-21
host: x86_64-pc-windows-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

If I use the command:

...>rustc --edition 2018 -Z unstable-options test.rs

The compilation seems OK. If I compile with:

...>rustc --edition 2021 -Z unstable-options test.rs

rustc gives an error without line numbers:

error: `$pattern:pat` may be followed by `|`, which is not allowed for `pat` fragments
    |
    = note: allowed there are: `=>`, `,`, `=`, `if` or `in`

error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-edition-2021Area: The 2021 editionA-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.P-highHigh 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