]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #88305 - ijackson:exitstatus-debug, r=dtolnay
authorManish Goregaokar <manishsmail@gmail.com>
Mon, 4 Oct 2021 06:13:18 +0000 (23:13 -0700)
committerGitHub <noreply@github.com>
Mon, 4 Oct 2021 06:13:18 +0000 (23:13 -0700)
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 #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

1  2 
library/std/src/sys/unix/process/process_unix.rs