-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Use new io in print and println macroses #23206
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
👍 |
I think this should rather call a function in // in src/libstd/io/mod.rs
#[doc(hidden)]
pub mod __print {
pub fn println(args: &fmt::Arguments) { ... }
pub fn print(args: &fmt::Arguments) { ... }
} We may want to also hold off on this for now for a little bit, I have a few reservations:
cc @aturon, do you have thoughts on this? |
@alexcrichton maybe |
@alexcrichton regarding the bloat: we are talking about Currently, as patch is now, this comes out to 17 insns (old) vs 30 insns (new) when optimised and ~50 insns (old) vs ~100 insns (new) without optimisations. Most of the additional overhead in the new version comes from multiple invocations of Regarding other points, I’m fine with holding the PR off until flushing at exit works. @hauleth I’d rather see EDIT: err, I didn’t account for all the drop glue in my instruction calculations. |
a872254
to
040a97e
Compare
Ah yeah I've found in the past that this introduces quite a bit more code to deal with the owned Basically I do agree that the differences are pretty minor, but for a super heavily used macro like |
☔ The latest upstream changes (presumably #23292) made this pull request unmergeable. Please resolve the merge conflicts. |
045ba62
to
1032da3
Compare
@@ -83,7 +84,8 @@ macro_rules! print { | |||
#[macro_export] | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
macro_rules! println { | |||
($($arg:tt)*) => ($crate::old_io::stdio::println_args(format_args!($($arg)*))) | |||
($fmt:expr) => (print!(concat!($fmt, "\n"))); | |||
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*)); |
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.
Nice!
@nagisa I think that for now we may wish to continuing capturing the output of tests just to preserve that compatibility temporarily. I ended up adding |
ded8dd9
to
38048f8
Compare
} | ||
map | ||
} | ||
|
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.
This code is not used anywhere, so I took liberty to get rid of it.
@bors: r+ 38048f8c0c794ca80e754af427c9f1c0d60ee3ce Thanks! |
⌛ Testing commit 38048f8 with merge a17aed7... |
💔 Test failed - auto-mac-64-opt |
I believe that test is not applicable anymore, hence the test goes away. |
@bors: r+ |
@@ -18,6 +19,13 @@ use io::{self, BufReader, LineWriter}; | |||
use sync::{Arc, Mutex, MutexGuard}; | |||
use sys::stdio; | |||
|
|||
/// Stdout used by print! and println! macroses |
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.
macros?
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.
Since this code is internal and docstring won’t appear in any public-facing documentation, I believe it is not worth updating this unless this bounces.
r? @alexcrichton or @aturon This still needs to somehow figure out how to avoid unstable warnings arising from the use of unstable functions. I tried to use `#[allow_internal_unstable]` but it still spits out warnings as far as I can see. @huonw (I think you implemented it) does `#[allow_internal_unstable]` not work for some reason or am I using it incorrectly?
r? @alexcrichton or @aturon
This still needs to somehow figure out how to avoid unstable warnings arising from the use of unstable functions. I tried to use
#[allow_internal_unstable]
but it still spits out warnings as far as I can see. @huonw (I think you implemented it) does#[allow_internal_unstable]
not work for some reason or am I using it incorrectly?