about summary refs log tree commit diff
path: root/tests/ui/write-fmt-errors.rs
diff options
context:
space:
mode:
authorThalia Archibald <thalia@archibald.dev>2025-02-14 13:40:24 -0800
committerThalia Archibald <thalia@archibald.dev>2025-03-10 01:38:20 -0700
commit523b9d942890f331fcee5d2d26e7cecfb59c6ec8 (patch)
treea0f3c1ca0f5c215c02c0fcfd2050c5004dc603cf /tests/ui/write-fmt-errors.rs
parent2c6a12ec44d0426c8939123c2f2cf27d2217de13 (diff)
downloadrust-523b9d942890f331fcee5d2d26e7cecfb59c6ec8.tar.gz
rust-523b9d942890f331fcee5d2d26e7cecfb59c6ec8.zip
Implement default methods for io::Empty and io::Sink
Eliminate any redundant, unobservable logic from the their default
method implementations.

The observable changes are that `Write::write_fmt` for both types now
ignores the formatting arguments, so a user fmt impl which has side
effects is not invoked, and `Write::write_all_vectored` for both types
does not advance the borrowed buffers. Neither behavior is guaranteed by
the docs and the latter is documented as unspecified.

`Empty` is not marked as vectored, so that `Chain<Empty, _>` and
`Chain<_, Empty>` are not forced to be vectored.
Diffstat (limited to 'tests/ui/write-fmt-errors.rs')
-rw-r--r--tests/ui/write-fmt-errors.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/ui/write-fmt-errors.rs b/tests/ui/write-fmt-errors.rs
index 1dafb9a784b..b48fa3f11cc 100644
--- a/tests/ui/write-fmt-errors.rs
+++ b/tests/ui/write-fmt-errors.rs
@@ -4,7 +4,7 @@
 #![feature(io_error_uncategorized)]
 
 use std::fmt;
-use std::io::{self, Error, Write, sink};
+use std::io::{self, Error, Write};
 use std::panic::catch_unwind;
 
 struct ErrorDisplay;
@@ -33,7 +33,7 @@ fn main() {
     assert!(res.is_err(), "writer error did not propagate");
 
     // Test that the error from the formatter is detected.
-    let res = catch_unwind(|| write!(sink(), "{} {} {}", 1, ErrorDisplay, "bar"));
+    let res = catch_unwind(|| write!(vec![], "{} {} {}", 1, ErrorDisplay, "bar"));
     let err = res.expect_err("formatter error did not lead to panic").downcast::<&str>().unwrap();
     assert!(
         err.contains("formatting trait implementation returned an error"),