Skip to content

Regression involving "is not a logical operator" in match #75599

Closed
@dtolnay

Description

@dtolnay

The following used to work from rust 1.0.0 through 1.41.0, but has been failing to compile since 1.42.0. I believe the "`and` is not a logical operator" diagnostic is being overzealous and should not be triggering on this program.

mod or {
    pub const ID: usize = 0;
}

mod and {
    pub const ID: usize = 1;
}

fn main() {
    match 0 {
        or::ID => {}
        and::ID => {}
        _ => {}
    }
}
error: `and` is not a logical operator
  --> src/main.rs:12:9
   |
12 |         and::ID => {}
   |         ^^^ help: use `&&` to perform logical conjunction
   |
   = note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions