Diagnostic on missing "?" suggests to ignore the error entirely, which can be problematic
Open
@roife is already working on this.
Since Sep 13, 2024.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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 https://github.com/rust-lang/miri/issues/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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.