Skip to content

Operators in patterns have incorrect priorities #48501

Open
@petrochenkov

Description

@petrochenkov

(Or at least unnatural priorities.)

Binary range operators have higher priority than unary operators like & or box.

#![feature(exclusive_range_pattern)]

fn main() {
    // Interpreted as (&0) .. (10), ERROR mismatched types
    let x = &0 .. 10;

    match &0 {
        &0 .. 10 => {} // OK?!
        _ => {}
    }
}

We can change the priorities for all the unstable kinds of ranges and come up with some deprecation story for stable BEGIN ... END.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-grammarArea: The grammar of RustA-parserArea: The lexing & parsing of Rust source code to an ASTA-patternsRelating to patterns and pattern matchingC-enhancementCategory: An issue proposing an enhancement or a PR with one.F-exclusive_range_pattern`#![feature(exclusive_range_pattern)]`F-half_open_range_patterns`#![feature(half_open_range_patterns)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language 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