-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Consider checking for formattee errors in ToString::to_string and format!() #40103
Comments
I think it is an error for an implementation of So +1 for panicking when that happens. |
Error as in programmer mistake, a bug. Not a |
It's documented here:
|
@ollie27 Oh thanks. |
@alexcrichton, you replaced |
@SimonSapin that was also three years ago as part of a 6kloc PR. Unfortunately no, I don't remember why that particular line is that way. It was likely because at the time I assumed that no one would ever manufacture |
… instead of silently ignoring a result. `fmt::Write for String` never returns `Err`, so implementations of `Display` (or other traits of that family) never should either. Fixes rust-lang#40103
…ter, r=alexcrichton Panic on errors in `format!` or `<T: Display>::to_string` … instead of silently ignoring a result. `fmt::Write for String` never returns `Err`, so implementations of `Display` (or other traits of that family) never should either. Fixes rust-lang#40103
…ter, r=alexcrichton Panic on errors in `format!` or `<T: Display>::to_string` … instead of silently ignoring a result. `fmt::Write for String` never returns `Err`, so implementations of `Display` (or other traits of that family) never should either. Fixes rust-lang#40103
…ter, r=alexcrichton Panic on errors in `format!` or `<T: Display>::to_string` … instead of silently ignoring a result. `fmt::Write for String` never returns `Err`, so implementations of `Display` (or other traits of that family) never should either. Fixes rust-lang#40103
In both
ToString
forT: Display
andformat!()
, it is assumed that noDisplay
implementation will ever returnErr(_)
because none of the methods ofWrite
forString
do.Given the
Display
trait does not document that it should not fail on its own, I think bothToString
forT: Display
types andformat!()
should unwrap the calls toWrite::write_fmt
instead of completely ignoring their result.The text was updated successfully, but these errors were encountered: