Skip to content

Commit 7a077b5

Browse files
committed
Migrate sink usages to empty
Signed-off-by: Alex Saveau <[email protected]>
1 parent f1ff3c1 commit 7a077b5

File tree

9 files changed

+19
-17
lines changed

9 files changed

+19
-17
lines changed

library/alloc/src/vec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ impl<T, A: Allocator> Vec<T, A> {
11811181
/// ```
11821182
/// use std::io::{self, Write};
11831183
/// let buffer = vec![1, 2, 3, 5, 8];
1184-
/// io::sink().write(buffer.as_slice()).unwrap();
1184+
/// io::empty().write(buffer.as_slice()).unwrap();
11851185
/// ```
11861186
#[inline]
11871187
#[stable(feature = "vec_as_slice", since = "1.7.0")]

library/std/src/io/buffered/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ fn bench_buffered_reader_small_reads(b: &mut test::Bencher) {
532532

533533
#[bench]
534534
fn bench_buffered_writer(b: &mut test::Bencher) {
535-
b.iter(|| BufWriter::new(io::sink()));
535+
b.iter(|| BufWriter::new(io::empty()));
536536
}
537537

538538
/// A simple `Write` target, designed to be wrapped by `LineWriter` /

library/std/src/io/copy/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::io::*;
66
#[test]
77
fn copy_copies() {
88
let mut r = repeat(0).take(4);
9-
let mut w = sink();
9+
let mut w = empty();
1010
assert_eq!(copy(&mut r, &mut w).unwrap(), 4);
1111

1212
let mut r = repeat(0).take(1 << 17);

library/std/src/io/util.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ pub struct Sink;
259259
/// # Examples
260260
///
261261
/// ```rust
262+
/// #![allow(deprecated_in_future)]
262263
/// use std::io::{self, Write};
263264
///
264265
/// let buffer = vec![1, 2, 3, 5, 8];
@@ -269,7 +270,7 @@ pub struct Sink;
269270
#[stable(feature = "rust1", since = "1.0.0")]
270271
#[rustc_const_unstable(feature = "const_io_structs", issue = "78812")]
271272
#[deprecated(since = "TBD", note = "superseded by `Empty`")]
272-
#[allow(deprecated_in_future)]
273+
#[allow(deprecated_in_future, dead_code)]
273274
pub const fn sink() -> Sink {
274275
Sink
275276
}

library/std/src/io/util/tests.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use crate::io::prelude::*;
2-
use crate::io::{empty, repeat, sink, BorrowedBuf, Empty, Repeat, SeekFrom, Sink};
2+
use crate::io::{self, empty, repeat, BorrowedBuf, Empty, Repeat, SeekFrom};
33

44
use crate::mem::MaybeUninit;
55

66
#[test]
7+
#[allow(deprecated_in_future)]
78
fn sink_sinks() {
8-
let mut s = sink();
9+
let mut s = io::sink();
910
assert_eq!(s.write(&[]).unwrap(), 0);
1011
assert_eq!(s.write(&[0]).unwrap(), 1);
1112
assert_eq!(s.write(&[0; 1024]).unwrap(), 1024);
@@ -90,8 +91,9 @@ fn take_some_bytes() {
9091
}
9192

9293
#[allow(dead_code)]
94+
#[allow(deprecated_in_future)]
9395
fn const_utils() {
9496
const _: Empty = empty();
9597
const _: Repeat = repeat(b'c');
96-
const _: Sink = sink();
98+
const _: io::Sink = io::sink();
9799
}

library/test/src/stats/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ macro_rules! assert_approx_eq {
1717
fn check(samples: &[f64], summ: &Summary) {
1818
let summ2 = Summary::new(samples);
1919

20-
let mut w = io::sink();
20+
let mut w = io::empty();
2121
let w = &mut w;
2222
(write!(w, "\n")).unwrap();
2323

src/librustdoc/doctest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ pub(crate) fn make_test(
562562
.diagnostic_width(Some(80))
563563
.supports_color();
564564

565-
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
565+
let emitter = EmitterWriter::new(Box::new(io::empty()), fallback_bundle);
566566

567567
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
568568
let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings();
@@ -738,7 +738,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
738738
false,
739739
);
740740

741-
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
741+
let emitter = EmitterWriter::new(Box::new(io::empty()), fallback_bundle);
742742

743743
let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings();
744744
let sess = ParseSess::with_span_handler(handler, sm);

src/tools/clippy/clippy_lints/src/doc.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
716716
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
717717
let fallback_bundle =
718718
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
719-
let emitter = EmitterWriter::new(
720-
Box::new(io::sink()),
721-
fallback_bundle,
722-
);
719+
let emitter = EmitterWriter::new(Box::new(io::empty()), fallback_bundle);
723720
let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings();
724721
let sess = ParseSess::with_span_handler(handler, sm);
725722

tests/ui/write-fmt-errors.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(io_error_uncategorized)]
44

55
use std::fmt;
6-
use std::io::{self, Error, Write, sink};
6+
use std::io::{self, empty, Error, Write};
77

88
struct ErrorDisplay;
99

@@ -23,12 +23,14 @@ impl Write for ErrorWriter {
2323
Err(Error::new(WRITER_ERROR, "not connected"))
2424
}
2525

26-
fn flush(&mut self) -> io::Result<()> { Ok(()) }
26+
fn flush(&mut self) -> io::Result<()> {
27+
Ok(())
28+
}
2729
}
2830

2931
fn main() {
3032
// Test that the error from the formatter is propagated.
31-
let res = write!(sink(), "{} {} {}", 1, ErrorDisplay, "bar");
33+
let res = write!(empty(), "{} {} {}", 1, ErrorDisplay, "bar");
3234
assert!(res.is_err(), "formatter error did not propagate");
3335
assert_eq!(res.unwrap_err().kind(), FORMAT_ERROR);
3436

0 commit comments

Comments
 (0)