mirror of
https://github.com/fafhrd91/actix-web
synced 2025-05-19 07:23:17 +02:00
chore: address clippy lints
This commit is contained in:
parent
ad73cdc823
commit
7eea3d3657
@ -1,4 +1,5 @@
|
||||
version: "0.2"
|
||||
words:
|
||||
- actix
|
||||
- httparse
|
||||
- rustup
|
||||
|
@ -31,7 +31,7 @@ async fn main() -> io::Result<()> {
|
||||
|
||||
actix_rt::time::sleep(Duration::from_secs(1)).await;
|
||||
|
||||
yield Err(io::Error::new(io::ErrorKind::Other, "abc"));
|
||||
yield Err(io::Error::other("abc"));
|
||||
})))
|
||||
})
|
||||
.tcp()
|
||||
|
@ -190,7 +190,7 @@ mod tests {
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn to_body_limit_error() {
|
||||
let err_stream = stream::once(async { Err(io::Error::new(io::ErrorKind::Other, "")) });
|
||||
let err_stream = stream::once(async { Err(io::Error::other("")) });
|
||||
let body = SizedStream::new(8, err_stream);
|
||||
// not too big, but propagates error from body stream
|
||||
assert!(to_bytes_limited(body, 10).await.unwrap().is_err());
|
||||
|
@ -100,10 +100,7 @@ where
|
||||
loop {
|
||||
if let Some(ref mut fut) = this.fut {
|
||||
let (chunk, decoder) = ready!(Pin::new(fut).poll(cx)).map_err(|_| {
|
||||
PayloadError::Io(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"Blocking task was cancelled unexpectedly",
|
||||
))
|
||||
PayloadError::Io(io::Error::other("Blocking task was cancelled unexpectedly"))
|
||||
})??;
|
||||
|
||||
*this.decoder = Some(decoder);
|
||||
|
@ -183,8 +183,7 @@ where
|
||||
if let Some(ref mut fut) = this.fut {
|
||||
let mut encoder = ready!(Pin::new(fut).poll(cx))
|
||||
.map_err(|_| {
|
||||
EncoderError::Io(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
EncoderError::Io(io::Error::other(
|
||||
"Blocking task was cancelled unexpectedly",
|
||||
))
|
||||
})?
|
||||
|
@ -415,7 +415,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_as_response() {
|
||||
let orig = io::Error::new(io::ErrorKind::Other, "other");
|
||||
let orig = io::Error::other("other");
|
||||
let err: Error = ParseError::Io(orig).into();
|
||||
assert_eq!(
|
||||
format!("{}", err),
|
||||
@ -425,14 +425,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_error_display() {
|
||||
let orig = io::Error::new(io::ErrorKind::Other, "other");
|
||||
let orig = io::Error::other("other");
|
||||
let err = Error::new_io().with_cause(orig);
|
||||
assert_eq!("connection error: other", err.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_error_http_response() {
|
||||
let orig = io::Error::new(io::ErrorKind::Other, "other");
|
||||
let orig = io::Error::other("other");
|
||||
let err = Error::new_io().with_cause(orig);
|
||||
let resp: Response<BoxBody> = err.into();
|
||||
assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR);
|
||||
@ -440,7 +440,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_payload_error() {
|
||||
let err: PayloadError = io::Error::new(io::ErrorKind::Other, "ParseError").into();
|
||||
let err: PayloadError = io::Error::other("ParseError").into();
|
||||
assert!(err.to_string().contains("ParseError"));
|
||||
|
||||
let err = PayloadError::Incomplete(None);
|
||||
@ -475,7 +475,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_from() {
|
||||
from_and_cause!(io::Error::new(io::ErrorKind::Other, "other") => ParseError::Io(..));
|
||||
from_and_cause!(io::Error::other("other") => ParseError::Io(..));
|
||||
from!(httparse::Error::HeaderName => ParseError::Header);
|
||||
from!(httparse::Error::HeaderName => ParseError::Header);
|
||||
from!(httparse::Error::HeaderValue => ParseError::Header);
|
||||
|
@ -310,10 +310,10 @@ impl MessageType for RequestHeadType {
|
||||
Version::HTTP_11 => "HTTP/1.1",
|
||||
Version::HTTP_2 => "HTTP/2.0",
|
||||
Version::HTTP_3 => "HTTP/3.0",
|
||||
_ => return Err(io::Error::new(io::ErrorKind::Other, "unsupported version")),
|
||||
_ => return Err(io::Error::other("Unsupported version")),
|
||||
}
|
||||
)
|
||||
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))
|
||||
.map_err(io::Error::other)
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ impl TransferEncoding {
|
||||
buf.extend_from_slice(b"0\r\n\r\n");
|
||||
} else {
|
||||
writeln!(helpers::MutWriter(buf), "{:X}\r", msg.len())
|
||||
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
|
||||
.map_err(io::Error::other)?;
|
||||
|
||||
buf.reserve(msg.len() + 2);
|
||||
buf.extend_from_slice(msg);
|
||||
|
@ -776,10 +776,7 @@ where
|
||||
}
|
||||
Poll::Pending => break,
|
||||
Poll::Ready(Some(Err(err))) => {
|
||||
return Poll::Ready(Some(Err(ProtocolError::Io(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("{err}"),
|
||||
)))));
|
||||
return Poll::Ready(Some(Err(ProtocolError::Io(io::Error::other(err)))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -795,11 +792,10 @@ where
|
||||
}
|
||||
Some(frm) => {
|
||||
let msg = match frm {
|
||||
Frame::Text(data) => {
|
||||
Message::Text(ByteString::try_from(data).map_err(|err| {
|
||||
ProtocolError::Io(io::Error::new(io::ErrorKind::Other, err))
|
||||
})?)
|
||||
}
|
||||
Frame::Text(data) => Message::Text(
|
||||
ByteString::try_from(data)
|
||||
.map_err(|err| ProtocolError::Io(io::Error::other(err)))?,
|
||||
),
|
||||
Frame::Binary(data) => Message::Binary(data),
|
||||
Frame::Ping(s) => Message::Ping(s),
|
||||
Frame::Pong(s) => Message::Pong(s),
|
||||
|
@ -1073,10 +1073,7 @@ fn bind_addrs(addrs: impl net::ToSocketAddrs, backlog: u32) -> io::Result<Vec<ne
|
||||
} else if let Some(err) = err.take() {
|
||||
Err(err)
|
||||
} else {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"Can not bind to address.",
|
||||
))
|
||||
Err(io::Error::other("Could not bind to address"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,9 +179,8 @@ where
|
||||
.acquire_owned()
|
||||
.await
|
||||
.map_err(|_| {
|
||||
ConnectError::Io(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"failed to acquire semaphore on client connection pool",
|
||||
ConnectError::Io(io::Error::other(
|
||||
"Failed to acquire semaphore on client connection pool",
|
||||
))
|
||||
})?;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user