-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-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 = Some(&(1, 2));
assert!(matches!(foo, &Some((1, 2))))
}
Current output
--> src/main.rs:3:27
|
3 | assert!(matches!(foo, &Some((1, 2))))
| --- ^^^^^^^^^^^^^ expected `Option<&({integer}, {integer})>`, found `&_`
| |
| this expression has type `Option<&({integer}, {integer})>`
|
= note: expected enum `Option<&({integer}, {integer})>`
found reference `&_`
help: try wrapping the pattern in `Some`
|
3 | assert!(matches!(foo, Some(&Some((1, 2)))))
| +++++ +
For more information about this error, try `rustc --explain E0308`.
Desired output
--> src/main.rs:3:27
|
3 | assert!(matches!(foo, &Some((1, 2))))
| --- ^^^^^^^^^^^^^ expected `Option<&({integer}, {integer})>`, found `&_`
| |
| this expression has type `Option<&({integer}, {integer})>`
|
= note: expected enum `Option<&({integer}, {integer})>`
found reference `&Option<_>`
help: try moving the borrow
|
3 | assert!(matches!(foo, &Some(&(1, 2)))))
| - +
For more information about this error, try `rustc --explain E0308`.
Rationale and extra context
No response
Other cases
Rust Version
1.91.0-nightly (2025-08-18 9eb4a2652031ed5ba97c)
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-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.