-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add conversions from File and Child* handles to Stdio #42133
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
The idea came from this question: |
Based on d0810ad, it looks like this is not a backwards-compatible change, since it changes the type signature of stdin, etc. Isn't that a problem? |
This sounds like a great idea to me! Now I'm surprised we didn't do this earlier... @droundy you're right that this is technically backwards-incompatible. For changes like this we typically run them through crater/cargobomb, automated systems to determine the amount of breakage in the ecosystem for a proposed change. I'll both tag this as needs-crater and also... @rfcbot fcp merge |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns: Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Right, it should be considered a minor change according to RFC1105 here. Note the fix changing Crater will tell us if this is widespread. If so, we can consider more explicit alternatives for the new functionality. e.g. We could revert the generic methods so you'd call |
Even if the crater run passes, I feel like the added generics are not pulling their weight. They make the signature more complex. @rfcbot concern into |
They do make the signature more complex, but that concern should be balanced against making the calling code simpler. Writing just |
I've started builds for a crater run
|
I've started building crates for crater. |
I see a lot of false positives... |
The first few I sampled look like infrastructure trouble, right?
|
All actual root regressions noted by crater appear to be network failures... so no root regressions? |
@BurntSushi mind elaborating a bit on your thoughts here? I personally feel like these are pretty nice signatures and our usage of |
To clarify: I don't feel that strongly about it and I'm fine removing my concern, but I did at least want to bring it up in case others felt similarly. I'm mostly just bleating about an issue that I think has problems in the aggregate, but is hard to nail down when talking about any one specific instance. For the most part, I just think that generic signatures add cognitive burden that makes them harder to understand. Basically, I would rather judge each instance on 1) its consistency with other uses of generics and 2) its bang-to-buck ratio. I think |
I do think the slight complication in the signature is outweighed by the simplification in every place that will call it. I find But I worry more about folks writing |
@rfcbot resolve into |
I am mildly concerned about the use of |
|
ping @brson, checkbox! |
Can we split the function signature change out? I really like the ability to get a |
If that's the consensus, I'll split it. My concern (as noted before) is that it will be hard to add later once people are manually converting. e.g. |
er sorry didn't mean to close |
src/libstd/process.rs
Outdated
@@ -753,6 +754,34 @@ impl fmt::Debug for Stdio { | |||
} | |||
} | |||
|
|||
#[stable(feature = "stdio_from", since = "1.19.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self, these will need to become 1.20.0 if we don't make it before the upcoming branch.
`Stdio` now implements `From<ChildStdin>`, `From<ChildStdout>`, `From<ChildStderr>`, and `From<File>`. The `Command::stdin`/`stdout`/`stderr` methods now take any type that implements `Into<Stdio>`. This makes it much easier to write shell-like command chains, piping to one another and redirecting to and from files. Otherwise one would need to use the unsafe and OS-specific `from_raw_fd` or `from_raw_handle`.
Rebased, squashed, and bumped to 1.20.0. It looks like everyone has checked off -- does @rfcbot need a nudge? |
📌 Commit 9debe91 has been approved by |
Add conversions from File and Child* handles to Stdio `Stdio` now implements `From<ChildStdin>`, `From<ChildStdout>`, `From<ChildStderr>`, and `From<File>`. The `Command::stdin`/`stdout`/`stderr` methods now take any type that implements `Into<Stdio>`. This makes it much easier to write shell-like command chains, piping to one another and redirecting to and from files. Otherwise one would need to use the unsafe and OS-specific `from_raw_fd` or `from_raw_handle`.
☀️ Test successful - status-appveyor, status-travis |
Stdio
now implementsFrom<ChildStdin>
,From<ChildStdout>
,From<ChildStderr>
, andFrom<File>
.The
Command::stdin
/stdout
/stderr
methods now take any type thatimplements
Into<Stdio>
.This makes it much easier to write shell-like command chains, piping to
one another and redirecting to and from files. Otherwise one would need
to use the unsafe and OS-specific
from_raw_fd
orfrom_raw_handle
.