Consider adding #[must_use] to std::process::ExitStatus #73127
Labels
A-process
Area: `std::process` and `std::env`
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Hi. Normally, Rust makes it difficult to accidentally write code which ignores errors. This is one of its great strengths. However, the
std::process
API requires the user to explicitly check the process exit status.(This issue is about the return value from
wait()
. I am filing another one aboutoutput()
. See also #70186 which is about the return value fromspawn()
.)Here's a demo of the problem.
(Playground)
It produces this output:
This is not optimal. I think making
ExitStatus
be#[must_use]
would be the best way to address this. The code above would then generate a compiler error. The programmer would be prompted to make an actual decision about the exit status.The text was updated successfully, but these errors were encountered: