Skip to content

Commit b036c8e

Browse files
committed
Replace Error::new(ErrorKind::Other, ...) with Error::other(...)
1 parent 5194cd9 commit b036c8e

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

crates/crates_io_tarball/src/limit_reader.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ impl<R: AsyncRead + Unpin> AsyncRead for LimitErrorReader<R> {
2525
) -> Poll<io::Result<()>> {
2626
let reader = Pin::new(&mut self.inner);
2727
match reader.poll_read(cx, buf) {
28-
Poll::Ready(Ok(())) if self.inner.limit() == 0 => Poll::Ready(Err(io::Error::new(
29-
io::ErrorKind::Other,
30-
"maximum limit reached when reading",
31-
))),
28+
Poll::Ready(Ok(())) if self.inner.limit() == 0 => {
29+
Poll::Ready(Err(io::Error::other("maximum limit reached when reading")))
30+
}
3231
e => e,
3332
}
3433
}

src/bin/crates-admin/render_readmes.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ async fn get_readme(
169169
));
170170
}
171171

172-
let reader = response
173-
.bytes_stream()
174-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e));
172+
let reader = response.bytes_stream().map_err(std::io::Error::other);
175173
let reader = StreamReader::new(reader);
176174
let reader = GzipDecoder::new(reader);
177175
let archive = Archive::new(reader);

src/controllers/krate/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const MAX_DESCRIPTION_LENGTH: usize = 1000;
6767
)]
6868
pub async fn publish(app: AppState, req: Parts, body: Body) -> AppResult<Json<GoodCrate>> {
6969
let stream = body.into_data_stream();
70-
let stream = stream.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err));
70+
let stream = stream.map_err(std::io::Error::other);
7171
let mut reader = StreamReader::new(stream);
7272

7373
// The format of the req.body() of a publish request is as follows:

src/sentry/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ mod tests {
113113
query_string: None,
114114
env: Default::default(),
115115
};
116-
let err = std::io::Error::new(std::io::ErrorKind::Other, "error");
116+
let err = std::io::Error::other("error");
117117

118118
let opts = options(SentryConfig::default());
119119
let event_req = req.clone();

src/util/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ mod tests {
311311
StatusCode::INTERNAL_SERVER_ERROR
312312
);
313313
assert_eq!(
314-
BoxedAppError::from(::std::io::Error::new(::std::io::ErrorKind::Other, ""))
314+
BoxedAppError::from(::std::io::Error::other(""))
315315
.response()
316316
.status(),
317317
StatusCode::INTERNAL_SERVER_ERROR

src/util/io_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn read_fill<R: Read + ?Sized>(r: &mut R, mut slice: &mut [u8]) -> io::Resul
1717
while !slice.is_empty() {
1818
let n = r.read(slice)?;
1919
if n == 0 {
20-
return Err(io::Error::new(io::ErrorKind::Other, "end of file reached"));
20+
return Err(io::Error::other("end of file reached"));
2121
}
2222
slice = &mut mem::take(&mut slice)[n..];
2323
}

0 commit comments

Comments
 (0)