-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
struct A(pub i32);
async fn example(Some(A(_)): Option<A>) {
}Current output
error[E0005]: refutable pattern in local binding
--> src/main.rs:7:12
|
7 | async fn example(Some(A(_)): Option<A>) {}
| ^^^^^^^^^^ pattern `None` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `Option<A>`
help: you might want to use `let else` to handle the variant that isn't matched
|
7 | async fn example(Some(A(_)) else { todo!() }: Option<A>) {}
| ++++++++++++++++
For more information about this error, try `rustc --explain E0005`.Desired output
error[E0005]: refutable pattern in function argument
--> src/main.rs:7:6
|
7 | fn example(Some(A(_)): Option<A>) {}
| ^^^^^^^^^^ pattern `None` not covered
|
= note: the matched value is of type `Option<A>`
For more information about this error, try `rustc --explain E0005`.Rationale and extra context
The desired output is what I get when I don't make the funtion async. So this
struct A(pub i32);
fn example(Some(A(_)): Option<A>) {}gives the desired output
Other cases
Rust Version
rustc 1.84.1 (e71f9a9a9 2025-01-27)
binary: rustc
commit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58
commit-date: 2025-01-27
host: x86_64-unknown-linux-gnu
release: 1.84.1
LLVM version: 19.1.5Anything else?
No response
Reactions are currently unavailable
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.