-
Notifications
You must be signed in to change notification settings - Fork 13.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
fn fallible() -> Result<i32, ()> {
Ok(42)
}
pub fn caller() -> Result<(), ()> {
fallible();
Ok(())
}
Current output
warning: unused `Result` that must be used
--> src/lib.rs:6:5
|
6 | fallible();
| ^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled
= note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
|
6 | let _ = fallible();
| +++++++
Desired output
Rust should suggest to add the missing `?`, not to ignore the error entirely.
Rationale and extra context
See rust-lang/miri#3855 for an example where ignoring the error with let _ =
can lead to critical bugs.
Other cases
No response
Rust Version
1.81.0
Anything 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.