1
Fork 0

io::Write::write_fmt: panic if the formatter fails when the stream does not fail

This commit is contained in:
Ralf Jung 2024-05-11 14:23:37 +02:00
parent ef15976387
commit e00f27b7be
3 changed files with 26 additions and 13 deletions

View file

@ -1839,7 +1839,11 @@ pub trait Write {
if output.error.is_err() {
output.error
} else {
Err(error::const_io_error!(ErrorKind::Uncategorized, "formatter error"))
// This shouldn't happen: the underlying stream did not error, but somehow
// the formatter still errored?
panic!(
"a formatting trait implementation returned an error when the underlying stream did not"
);
}
}
}