-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
fn main() {
let foo: Option<()> = Some(());
if matches!(Some(_), foo) {
println!("👍");
} else {
panic!();
}
}Current output
Compiling playground v0.0.1 (/playground)
error: in expressions, `_` can only be used on the left-hand side of an assignment
--> src/main.rs:3:22
|
3 | if matches!(Some(_), foo) {
| ^ `_` not allowed here
error: could not compile `playground` (bin "playground") due to 1 previous errorDesired output
The error should say something about how the arguments are in the wrong order. The phrase "error: in expressions, `_` can only be used on the left-hand side of an assignment" is confusing because does not appear to be an assignment, and the `_` is in the left-hand position.Rationale and extra context
Playground link here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024
Other cases
Rust Version
rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: x86_64-unknown-linux-gnu
release: 1.83.0
LLVM version: 19.1.1Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.