Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dtolnay opened this issue Aug 16, 2020 · 2 comments · Fixed by #75658
Closed

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

dtolnay opened this issue Aug 16, 2020 · 2 comments · Fixed by #75658
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Aug 16, 2020

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
@dtolnay dtolnay added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. C-bug Category: This is a bug. labels Aug 16, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 16, 2020
@dtolnay
Copy link
Member Author

dtolnay commented Aug 16, 2020

Likely introduced in #66994.

@dtolnay dtolnay added the A-parser Area: The parsing of Rust source code to an AST label Aug 16, 2020
@tgnottingham
Copy link
Contributor

@rustbot claim

tmandry added a commit to tmandry/rust that referenced this issue Aug 19, 2020
Don't emit "is not a logical operator" error outside of associative expressions

Avoid showing this error where it doesn't make sense by not assuming
"and" and "or" were intended to mean "&&" and "||" until after we decide
to continue parsing input as an associative expression.

Note that the decision of whether or not to continue parsing input as an
associative expression doesn't actually depend on this assumption.

Fixes rust-lang#75599

---

First time contributor! Let me know if there are any conventions or policies I should be following that I missed here. Thanks :)
tmandry added a commit to tmandry/rust that referenced this issue Aug 19, 2020
Don't emit "is not a logical operator" error outside of associative expressions

Avoid showing this error where it doesn't make sense by not assuming
"and" and "or" were intended to mean "&&" and "||" until after we decide
to continue parsing input as an associative expression.

Note that the decision of whether or not to continue parsing input as an
associative expression doesn't actually depend on this assumption.

Fixes rust-lang#75599

---

First time contributor! Let me know if there are any conventions or policies I should be following that I missed here. Thanks :)
tmandry added a commit to tmandry/rust that referenced this issue Aug 19, 2020
Don't emit "is not a logical operator" error outside of associative expressions

Avoid showing this error where it doesn't make sense by not assuming
"and" and "or" were intended to mean "&&" and "||" until after we decide
to continue parsing input as an associative expression.

Note that the decision of whether or not to continue parsing input as an
associative expression doesn't actually depend on this assumption.

Fixes rust-lang#75599

---

First time contributor! Let me know if there are any conventions or policies I should be following that I missed here. Thanks :)
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 19, 2020
Don't emit "is not a logical operator" error outside of associative expressions

Avoid showing this error where it doesn't make sense by not assuming
"and" and "or" were intended to mean "&&" and "||" until after we decide
to continue parsing input as an associative expression.

Note that the decision of whether or not to continue parsing input as an
associative expression doesn't actually depend on this assumption.

Fixes rust-lang#75599

---

First time contributor! Let me know if there are any conventions or policies I should be following that I missed here. Thanks :)
@bors bors closed this as completed in ff73a40 Aug 19, 2020
@spastorino spastorino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 19, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Aug 22, 2020
…xpressions

Avoid showing this error where it doesn't make sense by not assuming
"and" and "or" were intended to mean "&&" and "||" until after we decide
to continue parsing input as an associative expression.

Note that the decision of whether or not to continue parsing input as an
associative expression doesn't actually depend on this assumption.

Fixes rust-lang#75599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants