diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-02-26 02:53:47 +0100 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-02-26 02:59:25 +0100 |
| commit | 6cfafad3c56736a62e1043a8d01f7f2c74384008 (patch) | |
| tree | 51287410608ae9cf04ff019de6c4067d60c4b0a3 /src/libstd/io/mod.rs | |
| parent | 8842e28be8857e8e37591e2dec469d6720c278cb (diff) | |
| download | rust-6cfafad3c56736a62e1043a8d01f7f2c74384008.tar.gz rust-6cfafad3c56736a62e1043a8d01f7f2c74384008.zip | |
Make sure formatter errors are emitted by the default Write::write_fmt
Previously, if an error was returned from the formatter that did not originate in an underlying writer error, Write::write_fmt would return successfully even if the formatting did not complete (was interrupted by an `fmt::Error` return). Now we choose to emit an io::Error with kind Other for formatter errors. Since this may reveal error returns from `write!()` and similar that previously passed silently, it's a kind of a [breaking-change].
Diffstat (limited to 'src/libstd/io/mod.rs')
| -rw-r--r-- | src/libstd/io/mod.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index abb47b69418..4baf02063a3 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1055,7 +1055,14 @@ pub trait Write { let mut output = Adaptor { inner: self, error: Ok(()) }; match fmt::write(&mut output, fmt) { Ok(()) => Ok(()), - Err(..) => output.error + Err(..) => { + // check if the error came from the underlying `Write` or not + if output.error.is_err() { + output.error + } else { + Err(Error::new(ErrorKind::Other, "formatter error")) + } + } } } |
