-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 std::io::set_panic and set_print #31343
Comments
This is legacy behavior on behalf of libtest. The I don't think we should stabilize either of these (as evident by |
@DanielKeep was specifically interested in |
Currently, the code for doing this (replacing stdout) is platform-specific and really brittle (see Because of libstd's caching behaviour, the only way I can see to do this properly is to be able to explicitly replace the output writer. Also, consider that you often want to redirect stdout/stderr when working with GUI applications, either to an internal buffer or a log file. Remember that on Windows, GUI applications don't have the standard IO handles connected to anything. One point to note, however, is that the interception I'm doing is process-wide, whereas I believe fn set_process_stdout<W: Write + IntoRawFd>(write: W) -> io::Result<()> { ... }
fn set_thread_stdout<W: Write>(write: W) -> io::Result<()> { ... } |
The two functions in the original report were added as a short term hack and are not intended for stabilisation consideration. If the functionality is desired, an RFC with a proper proposal should be created IMO. |
If this is a short term hack, what will the |
What test crate is using is an implementation detail of (currently) internal component. I suppose test crate would start using the newly introduced stable functions once those become available. I do not argue against including this sort of functionality into libstd, but to me it sounds like there should be more design process for this and the process in question happens with RFCs (e.g. one obvious solution is to have something based on |
For the record, the stdout and stderr are ignored when running an Android app. EDIT: in fact no longer the case. |
For the record, see issue #35136 for an example where the test runner fouls up my test via I would prefer to see |
set_print() doesn't capture io through std::io::write(). Consider adding set_write() or perhaps making internal set_stdio() , if that would achieve the same result, public would provide io::write() capture. |
@SecondNature There is no |
Yes std::io::write() doesn't exist. My mistake. std::writeln!() redirection is required. Can capture println!() with set_print() but can't capture std::writeln!() as no set_write(). |
The |
We ran into a quirk of |
Would like to see these stabilized, so that Rust can produce CloudABI binaries without requiring nightly |
@mcandre Could you say more about how and why these functions are required for CloudABI? |
Hello, I think there is a huge difference between an "unstable" feauture such as set_print which has been basically unchanged for years and is used by cargo test and other experimental unstable feautures. I think either rust should allow certain unstable features to be used in stable as well with a warning, set_print being one example, or set_print should have the unstable removed. I really need this and it's really a shame that I can't do it at all in rust without being forced to use nightly |
I would like to see a stabilized implementation of this so that libraries such as gag would be able to become cross-platform in a reliable way. |
I would also love to see that stabilized. The |
I'm not really sure So rather than stabilize |
I and other guys agree with @wdanilo - it would be super useful for WASM apps. |
Closing this, since these functions no longer exist since 1.50 (#78714). |
@m-ou-se I see you've done some changes related to Could you please write us about future plans with Can we help somehow to make Thank you! |
@MartinKavik There are no concrete plans here. The original feature ( In general, the situation of wasm in the standard library is pretty bad. Almost everything from Ping @alexcrichton: I believe you know more about the situation of wasm in the rust standard library. |
Unfortunately there's no real story for something like |
Say, I'm entirely new to rust, trying to get encrusted going, which, in turn, uses wasm-glue (doc.rs here) In wasm-glue's source file lib.rs, it's apparently still using What is the replacement? Being new to rust, and poking through the docs, I'm not finding anything obvious, thinking this change was done fairly quietly. I'd like to submit an update to wasm-glue. Thanks. |
There's no replacement, because these functions never actually existed in stable Rust at all. The code you linked relied on a nightly feature, making use of an internal implementation detail of some older versions of Rust that wasn't meant for that purpose. A solution might be for that crate to provide its own Another solution could be to add some new feature to Rust's standard library (for wasm only, or for all platforms) that can be used for this. A design for that could be proposed in an RFC. |
Thank you for the reply. It's not my code, I was just hoping to be able to contribute a fix for it. I'd be comfortable developing a fix to the existing wasm-glue code, but since I'm new to rust, designing a new solution may be a bit out of my wheelhouse right now. |
std::io
contains these two public unstable functions:They both have
#[doc(hidden)]
. Anyone knows why?The also both have:
Their functionality is evidently useful, since the
test
crate uses them to capture the output of tests on only show it when they fail. External test harnesses would likely want to have similar functionality.This issue is about eventually stabilizing either these functions or a more general mechanism.
For
set_panic
, that mechanism might be panic handlers (#30449) though it would be nice to be able to not duplicate most of the work done in the default handler just to change the output stream. This still leavesset_print
.The text was updated successfully, but these errors were encountered: