-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
std: Stabilize std::fmt #19040
std: Stabilize std::fmt #19040
Conversation
r? @aturon |
c534545
to
84d2517
Compare
r=me after a rebase |
84d2517
to
fac3672
Compare
Needs rebase. |
This commit applies the stabilization of std::fmt as outlined in [RFC 380][rfc]. There are a number of breaking changes as a part of this commit which will need to be handled to migrated old code: * A number of formatting traits have been removed: String, Bool, Char, Unsigned, Signed, and Float. It is recommended to instead use Show wherever possible or to use adaptor structs to implement other methods of formatting. * The format specifier for Boolean has changed from `t` to `b`. * The enum `FormatError` has been renamed to `Error` as well as becoming a unit struct instead of an enum. The `WriteError` variant no longer exists. * The `format_args_method!` macro has been removed with no replacement. Alter code to use the `format_args!` macro instead. * The public fields of a `Formatter` have become read-only with no replacement. Use a new formatting string to alter the formatting flags in combination with the `write!` macro. The fields can be accessed through accessor methods on the `Formatter` structure. Other than these breaking changes, the contents of std::fmt should now also all contain stability markers. Most of them are still #[unstable] or #[experimental] [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0380-stabilize-std-fmt.md [breaking-change] Closes rust-lang#18904
fac3672
to
4af3494
Compare
@@ -277,6 +281,7 @@ macro_rules! writeln( | |||
/// Equivalent to the `println!` macro except that a newline is not printed at | |||
/// the end of the message. | |||
#[macro_export] | |||
#[stable] |
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.
It seems premature to mark this as stable when the design of the stdio support is in question. It's not possible to either handle or ignore runtime errors from these functions like broken pipes. The handling of buffering has also been called out as confusing / inefficient, and I don't see why writing to stdout
should involve virtual method calls.
Moving response to #19040 (comment) out of the commit and onto the PR itself, so that notifications are sent out more generally.
It does take a lot of time to keep up, I agree (though I find it much easier to track RFCs than individual PRs). What can I say, there's a lot going on!
Yes, I agree, and marking it stable is committing to not returning a value and performing buffering.
It seems to me that panic is pretty reasonable (it's also what other languages do). Programs that do not require fine-grained error handling (like many command-line utilities) can thus use In any case, this discussion has come up numerous times before (e.g., here). The arguments for/against have been made. I think it's time for this commit to move forward and this argument to be closed. |
#include <stdio.h>
int
main(void)
{
for(size_t i = 0; i < 100; ++i){
printf("Hello\n");
fflush(stdout);
}
return 0;
}
|
@Earnestly it would be helpful for you to explain what you're trying to say instead of just posting code and assuming others will infer. C's behavior has been discussed in great detail on #13824 (which @nikomatsakis linked to), and I recommend reading when discussion the SIGPIPE issue. |
Just thought it would be fair to include a language that is remotely related to Rust. People can read about your strace as you linked. |
@nikomatsakis: Exceptions that can be caught are not compared to aborting the process / task. |
This commit applies the stabilization of std::fmt as outlined in RFC 380.
There are a number of breaking changes as a part of this commit which will need
to be handled to migrated old code:
Signed, and Float. It is recommended to instead use Show wherever possible or
to use adaptor structs to implement other methods of formatting.
t
tob
.FormatError
has been renamed toError
as well as becoming a unitstruct instead of an enum. The
WriteError
variant no longer exists.format_args_method!
macro has been removed with no replacement. Altercode to use the
format_args!
macro instead.Formatter
have become read-only with no replacement.Use a new formatting string to alter the formatting flags in combination with
the
write!
macro. The fields can be accessed through accessor methods on theFormatter
structure.Other than these breaking changes, the contents of std::fmt should now also all
contain stability markers. Most of them are still #[unstable] or #[experimental]
[breaking-change]
Closes #18904