Skip to content

Commit c5e2325

Browse files
committed
Fix more warnings.
1 parent 8a3148f commit c5e2325

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

tests/buffered.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,14 +469,17 @@ fn panic_in_write_doesnt_flush_in_drop() {
469469
assert_eq!(WRITES.load(Ordering::SeqCst), 1);
470470
}
471471

472+
#[cfg(bench)]
472473
struct Empty;
473474

475+
#[cfg(bench)]
474476
impl Read for Empty {
475477
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
476478
Ok(0)
477479
}
478480
}
479481

482+
#[cfg(bench)]
480483
impl Write for Empty {
481484
fn write(&mut self, _data: &[u8]) -> io::Result<usize> {
482485
panic!("Empty doesn't support writing")
@@ -493,14 +496,17 @@ fn bench_buffered_reader(b: &mut test::bench::Bencher) {
493496
b.iter(|| BufDuplexer::new(JustWriter(Empty)));
494497
}
495498

499+
#[cfg(bench)]
496500
struct Sink;
497501

502+
#[cfg(bench)]
498503
impl Read for Sink {
499504
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
500505
panic!("Sink doesn't support reading")
501506
}
502507
}
503508

509+
#[cfg(bench)]
504510
impl Write for Sink {
505511
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
506512
Ok(data.len())

tests/tests.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use cap_tempfile::{ambient_authority, tempdir, TempDir};
55
#[cfg(not(target_os = "wasi"))]
66
use io_streams::StreamDuplexer;
77
use io_streams::{StreamReader, StreamWriter};
8-
use std::io::{self, copy, Read, Write};
8+
use std::io::{copy, Read, Write};
99
#[cfg(all(not(target_os = "wasi"), feature = "socketpair"))]
1010
use {socketpair::SocketpairStream, std::str};
1111

@@ -155,7 +155,7 @@ fn test_null_duplex() -> anyhow::Result<()> {
155155
#[test]
156156
fn test_socketed_thread_func() -> anyhow::Result<()> {
157157
let mut thread = StreamDuplexer::socketed_thread_func(Box::new(
158-
|mut stream: SocketpairStream| -> io::Result<SocketpairStream> {
158+
|mut stream: SocketpairStream| -> std::io::Result<SocketpairStream> {
159159
let mut buf = [0_u8; 4096];
160160
let n = stream.read(&mut buf)?;
161161
assert_eq!(str::from_utf8(&buf[..n]).unwrap(), "hello world\n");
@@ -182,10 +182,12 @@ fn test_socketed_thread_func() -> anyhow::Result<()> {
182182
Ok(())
183183
}
184184

185+
#[cfg(all(not(target_os = "wasi"), feature = "socketpair"))]
185186
struct Mock(bool);
186187

188+
#[cfg(all(not(target_os = "wasi"), feature = "socketpair"))]
187189
impl Read for Mock {
188-
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
190+
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
189191
assert!(!self.0);
190192
self.0 = true;
191193
assert!(!buf.is_empty());
@@ -195,21 +197,23 @@ impl Read for Mock {
195197
}
196198
}
197199

200+
#[cfg(all(not(target_os = "wasi"), feature = "socketpair"))]
198201
impl Write for Mock {
199-
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
202+
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
200203
assert!(self.0);
201204
self.0 = false;
202205
assert_eq!(buf, &vec![0xcd_u8; buf.len()][..]);
203206
Ok(buf.len())
204207
}
205208

206-
fn flush(&mut self) -> io::Result<()> {
209+
fn flush(&mut self) -> std::io::Result<()> {
207210
Ok(())
208211
}
209212
}
210213

214+
#[cfg(all(not(target_os = "wasi"), feature = "socketpair"))]
211215
impl system_interface::io::ReadReady for Mock {
212-
fn num_ready_bytes(&self) -> io::Result<u64> {
216+
fn num_ready_bytes(&self) -> std::io::Result<u64> {
213217
if self.0 {
214218
Ok(0)
215219
} else {
@@ -218,6 +222,7 @@ impl system_interface::io::ReadReady for Mock {
218222
}
219223
}
220224

225+
#[cfg(all(not(target_os = "wasi"), feature = "socketpair"))]
221226
impl duplex::Duplex for Mock {}
222227

223228
#[cfg(all(not(target_os = "wasi"), feature = "socketpair"))]

0 commit comments

Comments
 (0)