Skip to content

Commit d6abf69

Browse files
committed
std::process (unsupported): Implement From<io::Stdout> etc. for imp::Stdio
This implementation is wrong. Like the impl for From<File>, it is forced to panic because process::Stdio in unsupported/process.rs doesn't have a suitable variant. The root cause of the problem is that process::Stdio in unsupported/process.rs has any information in it at all. I'm pretty sure that it should just be a unit struct. However, making that build on all platforms is going to be a lot of work, iterating through CI and/or wrestling Docker. I don't think this extra panic is making things significantly worse. For now I have added some TODOs.
1 parent 36295fa commit d6abf69

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

library/std/src/sys/unsupported/process.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub struct StdioPipes {
2727
pub stderr: Option<AnonPipe>,
2828
}
2929

30+
// TODO: This should be a unti struct, so we can always construct it
31+
// The value here should be never used, since we cannot spawn processes.
3032
pub enum Stdio {
3133
Inherit,
3234
Null,
@@ -87,8 +89,26 @@ impl From<AnonPipe> for Stdio {
8789
}
8890
}
8991

92+
impl From<io::Stdout> for Stdio {
93+
fn from(_: io::Stdout) -> Stdio {
94+
// This is wrong.
95+
// Instead, the Stdio we have here should be a unit struct.
96+
panic!("unsupported")
97+
}
98+
}
99+
100+
impl From<io::Stderr> for Stdio {
101+
fn from(_: io::Stderr) -> Stdio {
102+
// This is wrong.
103+
// Instead, the Stdio we have here should be a unit struct.
104+
panic!("unsupported")
105+
}
106+
}
107+
90108
impl From<File> for Stdio {
91109
fn from(_file: File) -> Stdio {
110+
// This is wrong.
111+
// Instead, the Stdio we have here should be a unit struct.
92112
panic!("unsupported")
93113
}
94114
}

0 commit comments

Comments
 (0)