Skip to content

Manual Debug for Unix ExitCode ExitStatus ExitStatusError - #88305

Merged
bors merged 1 commit into
rust-lang:masterfrom
ijackson:exitstatus-debug
Oct 4, 2021
Merged

Manual Debug for Unix ExitCode ExitStatus ExitStatusError#88305
bors merged 1 commit into
rust-lang:masterfrom
ijackson:exitstatus-debug

Conversation

@ijackson

Copy link
Copy Markdown
Contributor

These structs have misleading names. An ExitStatus[Error] is actually a Unix wait status; an ExitCode is actually an exit status. These misleading names appear in the Debug output.

The Display impls on Unix have been improved, but the Debug impls are still misleading, as reported in #74832.

Fix this by pretending that these internal structs are called unix_exit_status and unix_wait_status as applicable. (We can't actually rename the structs because of the way that the cross-platform machinery works: the names are cross-platform.)

After this change, this program

#![feature(exit_status_error)]
fn main(){
let x = std::process::Command::new("false").status().unwrap();
dbg!(x.exit_ok());
eprintln!("x={:?}",x);
}

produces this output

[src/main.rs:4] x.exit_ok() = Err(
ExitStatusError(
unix_wait_status(
256,
),
),
)
x=ExitStatus(unix_wait_status(256))

Closes#74832

These structs have misleading names. An ExitStatus[Error] is actually
a Unix wait status; an ExitCode is actually an exit status.
The Display impls are fixed, but the Debug impls are still misleading,
as reported in rust-lang#74832.
Fix this by pretending that these internal structs are called
`unix_exit_status` and `unix_wait_status` as applicable. (We can't
actually rename the structs because of the way that the cross-platform
machinery works: the names are cross-platform.)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @m-ou-se

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 24, 2021
@inquisitivecrystalinquisitivecrystal added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Aug 24, 2021
@JohnCSimonJohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 12, 2021
@JohnCSimonJohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 28, 2021

@dtolnaydtolnay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@dtolnay

Copy link
Copy Markdown
Member

@bors r+ rollup

@bors

bors commented Oct 3, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 848a38a has been approved by dtolnay

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 3, 2021
@dtolnaydtolnay assigned dtolnay and unassigned m-ou-seOct 3, 2021
Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 4, 2021
Manual Debug for Unix ExitCode ExitStatus ExitStatusError
These structs have misleading names. An ExitStatus[Error] is actually a Unix wait status; an ExitCode is actually an exit status. These misleading names appear in the `Debug` output.
The `Display` impls on Unix have been improved, but the `Debug` impls are still misleading, as reported in rust-lang#74832.
Fix this by pretending that these internal structs are called `unix_exit_status` and `unix_wait_status` as applicable. (We can't actually rename the structs because of the way that the cross-platform machinery works: the names are cross-platform.)
After this change, this program
```
#![feature(exit_status_error)]
fn main(){
let x = std::process::Command::new("false").status().unwrap();
dbg!(x.exit_ok());
eprintln!("x={:?}",x);
}
```
produces this output
```
[src/main.rs:4] x.exit_ok() = Err(
ExitStatusError(
unix_wait_status(
256,
),
),
)
x=ExitStatus(unix_wait_status(256))
```
Closesrust-lang#74832
This was referenced Oct 4, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 4, 2021
…arth
Rollup of 14 pull requests
Successful merges:
- rust-lang#86434 (Add `Ipv6Addr::is_benchmarking`)
- rust-lang#86828 (const fn for option copied, take & replace)
- rust-lang#87679 (BTree: refine some comments)
- rust-lang#87910 (Mark unsafe methods NonZero*::unchecked_(add|mul) as const.)
- rust-lang#88286 (Remove unnecessary unsafe block in `process_unix`)
- rust-lang#88305 (Manual Debug for Unix ExitCode ExitStatus ExitStatusError)
- rust-lang#88353 (Partially stabilize `array_methods`)
- rust-lang#88370 (Add missing `# Panics` section to `Vec` method)
- rust-lang#88481 (Remove some feature gates)
- rust-lang#89138 (Fix link in Ipv6Addr::to_ipv4 docs)
- rust-lang#89401 (Add truncate note to Vec::resize)
- rust-lang#89467 (Fix typos in rustdoc/lints)
- rust-lang#89472 (Only register `WSACleanup` if `WSAStartup` is actually ever called)
- rust-lang#89505 (Add regression test for spurious const error with NLL)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit e4d257e into rust-lang:masterOct 4, 2021
@rustbotrustbot added this to the 1.57.0 milestone Oct 4, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ExitStatus Debug instance is misleading

8 participants

@ijackson@rust-highfive@dtolnay@bors@m-ou-se@JohnCSimon@inquisitivecrystal@rustbot