Rollup merge of #115489 - saethlin:is-interrupted, r=thomcc
Use std::io::Error::is_interrupted everywhere In https://github.com/rust-lang/rust/pull/115228 I introduced this helper and started using it, this PR uses it to replace all applicable uses of `std::io::Error::kind`. The justification is the same; for whatever reason LLVM totally flops optimizing `Error::kind` so it's nice to use it less. FYI ``@mkroening`` I swear the hermit changes look good, but I was so sure about the previous PR.
This commit is contained in:
commit
33e2e71502
11 changed files with 18 additions and 17 deletions
|
@ -237,7 +237,7 @@ impl<W: ?Sized + Write> BufWriter<W> {
|
|||
));
|
||||
}
|
||||
Ok(n) => guard.consume(n),
|
||||
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{BorrowedBuf, BufReader, BufWriter, ErrorKind, Read, Result, Write, DEFAULT_BUF_SIZE};
|
||||
use super::{BorrowedBuf, BufReader, BufWriter, Read, Result, Write, DEFAULT_BUF_SIZE};
|
||||
use crate::alloc::Allocator;
|
||||
use crate::cmp;
|
||||
use crate::collections::VecDeque;
|
||||
|
@ -30,6 +30,7 @@ mod tests;
|
|||
///
|
||||
/// [`read`]: Read::read
|
||||
/// [`write`]: Write::write
|
||||
/// [`ErrorKind::Interrupted`]: crate::io::ErrorKind::Interrupted
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -163,7 +164,7 @@ where
|
|||
// from adding I: Read
|
||||
match self.read(&mut []) {
|
||||
Ok(_) => {}
|
||||
Err(e) if e.kind() == ErrorKind::Interrupted => continue,
|
||||
Err(e) if e.is_interrupted() => continue,
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
let buf = self.buffer();
|
||||
|
@ -243,7 +244,7 @@ impl<I: Write + ?Sized> BufferedWriterSpec for BufWriter<I> {
|
|||
// Read again if the buffer still has enough capacity, as BufWriter itself would do
|
||||
// This will occur if the reader returns short reads
|
||||
}
|
||||
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
} else {
|
||||
|
@ -275,7 +276,7 @@ impl<A: Allocator> BufferedWriterSpec for Vec<u8, A> {
|
|||
let mut buf: BorrowedBuf<'_> = self.spare_capacity_mut().into();
|
||||
match reader.read_buf(buf.unfilled()) {
|
||||
Ok(()) => {}
|
||||
Err(e) if e.kind() == ErrorKind::Interrupted => continue,
|
||||
Err(e) if e.is_interrupted() => continue,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
||||
|
@ -307,7 +308,7 @@ fn stack_buffer_copy<R: Read + ?Sized, W: Write + ?Sized>(
|
|||
loop {
|
||||
match reader.read_buf(buf.unfilled()) {
|
||||
Ok(()) => {}
|
||||
Err(e) if e.kind() == ErrorKind::Interrupted => continue,
|
||||
Err(e) if e.is_interrupted() => continue,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
||||
|
|
|
@ -1647,7 +1647,7 @@ pub trait Write {
|
|||
));
|
||||
}
|
||||
Ok(n) => IoSlice::advance_slices(&mut bufs, n),
|
||||
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ pub trait FileExt {
|
|||
buf = &mut tmp[n..];
|
||||
offset += n as u64;
|
||||
}
|
||||
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ pub trait FileExt {
|
|||
buf = &buf[n..];
|
||||
offset += n as u64
|
||||
}
|
||||
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ pub trait FileExt {
|
|||
buf = &mut tmp[n..];
|
||||
offset += n as u64;
|
||||
}
|
||||
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ pub trait FileExt {
|
|||
buf = &buf[n..];
|
||||
offset += n as u64
|
||||
}
|
||||
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ where
|
|||
{
|
||||
loop {
|
||||
match cvt(f()) {
|
||||
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
other => return other,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ impl Socket {
|
|||
match unsafe { netc::poll(&mut pollfd, 1, timeout) } {
|
||||
-1 => {
|
||||
let err = io::Error::last_os_error();
|
||||
if err.kind() != io::ErrorKind::Interrupted {
|
||||
if !err.is_interrupted() {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -792,7 +792,7 @@ impl Drop for Dir {
|
|||
fn drop(&mut self) {
|
||||
let r = unsafe { libc::closedir(self.0) };
|
||||
assert!(
|
||||
r == 0 || crate::io::Error::last_os_error().kind() == crate::io::ErrorKind::Interrupted,
|
||||
r == 0 || crate::io::Error::last_os_error().is_interrupted(),
|
||||
"unexpected error during closedir: {:?}",
|
||||
crate::io::Error::last_os_error()
|
||||
);
|
||||
|
|
|
@ -320,7 +320,7 @@ where
|
|||
{
|
||||
loop {
|
||||
match cvt(f()) {
|
||||
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
other => return other,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ impl Socket {
|
|||
match unsafe { libc::poll(&mut pollfd, 1, timeout) } {
|
||||
-1 => {
|
||||
let err = io::Error::last_os_error();
|
||||
if err.kind() != io::ErrorKind::Interrupted {
|
||||
if !err.is_interrupted() {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ impl Command {
|
|||
assert!(p.wait().is_ok(), "wait() should either return Ok or panic");
|
||||
return Err(Error::from_raw_os_error(errno));
|
||||
}
|
||||
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
||||
Err(ref e) if e.is_interrupted() => {}
|
||||
Err(e) => {
|
||||
assert!(p.wait().is_ok(), "wait() should either return Ok or panic");
|
||||
panic!("the CLOEXEC pipe failed: {e:?}")
|
||||
|
|
Loading…
Add table
Reference in a new issue