-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking Issue for ExitStatusError #84908
Comments
Can you also add a note about implementing related: #54889 |
Late to the party, but the double unwrap seems like it should be avoidable. Is that in the plan? |
I have a plan for it :-) The reason for the two unwraps is this: I agree that this is suboptimal, particularly in simple cases where the error handling can be unsophisticated (but obvs. still wants to be correct). I think the fix is to provide I plan to do that but right now I am waiting for the dust to settle around some other changes I am trying to make to |
I don't know. I for one feel like the double unwrap is a useful property of this API, since those errors are coming from fundamentally different sources. The former comes from the OS when trying to setup the subprocess where as the latter represents the exit status of the process itself. I'd prefer to leave unifying the |
I don't think it would produce less contextually relevant errors. But I think I can best demonstrate that by prototyping it and showing what the error messages are that come out. So I will do that. It would also be possible to introduce the new I have a secret other reason for wanting an |
I did some experiments with |
I'm less worried about the |
@yaahc I have been thinking about this and have convinced myself that
I can't speak to Windows. But on Unix,
I don't think these are readily confuseable with the kinds of things that go wrong with the process itself. Additionally, of course, if the process failed it probably printed something to stderr itself. Hopefully the user can see that. And, of course, this new impl needs a new |
I think I agree that we probably want this and that the diagnostics won't be confusable but I'd like to add some tests for the various cases just to ensure we know exactly what output we're expecting. Just some basic tests in some new directory like Edit: I just realized the PR you opened has an example which tests exactly this for the case where the command itself fails. I'd like to do the same thing for the case where setting up the command is the part that fails to compare to make sure they're unambiguous, and if possible I'd like to make the same test work on windows / macos so we can make sure none of the platforms have major gaps in their diagnostics, but it's looking good so far.
Not following what you mean by "And, of course, this new impl needs a new |
:-). Sorry for not mentioning this explicitly...
The tests in
I think macos is
Roughtly that. An error kind to indicate that the problem was a subprocess failure and that it probably contains an Maybe we should continue this converation in the MR discussion? |
I believe the impl on ExitStatusError should be impl From<ExitStatusError> for ExitStatus rather than impl Into<ExitStatus> for ExitStatusError (there is generally never anything implemented as |
Hi! What are next steps for stabilizing this? The checklist in the OP does not appear to contain any blockers, so is this good to move to FCP? |
See rust-lang/rfcs#3362, which might be an alternative to stabilising |
Convert `Into<ExitStatus> for ExitStatusError` to `From<ExitStatusError> for ExitStatus` in `std::process` Implementing suggestion from rust-lang#84908 (comment): > I believe the impl on ExitStatusError should be > > ```rust > impl From<ExitStatusError> for ExitStatus > ``` > > rather than > > ```rust > impl Into<ExitStatus> for ExitStatusError > ``` > > (there is generally never anything implemented as `Into` first, because implementing `From` reflexively provides `Into`)
Convert `Into<ExitStatus> for ExitStatusError` to `From<ExitStatusError> for ExitStatus` in `std::process` Implementing suggestion from rust-lang/rust#84908 (comment): > I believe the impl on ExitStatusError should be > > ```rust > impl From<ExitStatusError> for ExitStatus > ``` > > rather than > > ```rust > impl Into<ExitStatus> for ExitStatusError > ``` > > (there is generally never anything implemented as `Into` first, because implementing `From` reflexively provides `Into`)
Convert `Into<ExitStatus> for ExitStatusError` to `From<ExitStatusError> for ExitStatus` in `std::process` Implementing suggestion from rust-lang/rust#84908 (comment): > I believe the impl on ExitStatusError should be > > ```rust > impl From<ExitStatusError> for ExitStatus > ``` > > rather than > > ```rust > impl Into<ExitStatus> for ExitStatusError > ``` > > (there is generally never anything implemented as `Into` first, because implementing `From` reflexively provides `Into`)
Convert `Into<ExitStatus> for ExitStatusError` to `From<ExitStatusError> for ExitStatus` in `std::process` Implementing suggestion from rust-lang/rust#84908 (comment): > I believe the impl on ExitStatusError should be > > ```rust > impl From<ExitStatusError> for ExitStatus > ``` > > rather than > > ```rust > impl Into<ExitStatus> for ExitStatusError > ``` > > (there is generally never anything implemented as `Into` first, because implementing `From` reflexively provides `Into`)
This change adds `fenix` to the nix flake to enable the use of nightly toolchains. Using nightly rust toolchains enables the use of the features behind the `exit_status_error`[^1] feature flag, which allows the use of `ExitStatusError`[^2]. [^1]: rust-lang/rust#84908 [^2]: https://doc.rust-lang.org/std/process/struct.ExitStatusError.html
This change adds `fenix` to the nix flake to enable the use of nightly toolchains. Using nightly rust toolchains enables the use of the features behind the `exit_status_error`[^1] feature flag, which allows the use of `ExitStatusError`[^2]. [^1]: rust-lang/rust#84908 [^2]: https://doc.rust-lang.org/std/process/struct.ExitStatusError.html
Feature gate:
#![feature(exit_status_error)]
This is a tracking issue for
ExitStatusError
(andExitStatus::exit_ok
).This feature makes it convenient to properly check the exit status of subprocesses (such as from
Command
)Example
Public API
(In pseudo-syntax:)
Steps / History
ExitStatus
docs)#[must_use]
toprocess::ExitStatus
(previous attempt Add #[must_use] to process::Command, process::Child and process::ExitStatus #81452); see also Tracking Issue for std::process error handling #73131.Try
forExitStatus
Unresolved Questions
The text was updated successfully, but these errors were encountered: