Skip to content

Commit 14f84f3

Browse files
committed
write-fmt-errors
1 parent d08fb12 commit 14f84f3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tests/ui/io-checks/write-macro-error.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Tests that errors from both the writer (`Write::write`) and formatter (`Display::fmt`)
2+
//! are correctly propagated: writer errors return `Err`, formatter errors cause panics.
3+
14
//@ run-pass
25
//@ needs-unwind
36

@@ -24,7 +27,9 @@ impl Write for ErrorWriter {
2427
Err(Error::new(WRITER_ERROR, "not connected"))
2528
}
2629

27-
fn flush(&mut self) -> io::Result<()> { Ok(()) }
30+
fn flush(&mut self) -> io::Result<()> {
31+
Ok(())
32+
}
2833
}
2934

3035
fn main() {
@@ -37,7 +42,8 @@ fn main() {
3742
let err = res.expect_err("formatter error did not lead to panic").downcast::<&str>().unwrap();
3843
assert!(
3944
err.contains("formatting trait implementation returned an error"),
40-
"unexpected panic: {}", err
45+
"unexpected panic: {}",
46+
err
4147
);
4248

4349
// Writer error when there's some string before the first `{}`
@@ -50,6 +56,7 @@ fn main() {
5056
let err = res.expect_err("formatter error did not lead to panic").downcast::<&str>().unwrap();
5157
assert!(
5258
err.contains("formatting trait implementation returned an error"),
53-
"unexpected panic: {}", err
59+
"unexpected panic: {}",
60+
err
5461
);
5562
}

0 commit comments

Comments
 (0)