fix clippy lints from the future (#3438)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
Because the build pipeline is checking for these.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
This commit is contained in:
Zelda Hessler 2024-02-26 09:30:51 -06:00 committed by GitHub
parent 07c8074ce5
commit 5b9d0c0fff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 19 additions and 30 deletions

View File

@ -104,14 +104,17 @@ mod tests {
use bytes::Buf;
use bytes_utils::SegmentedBuf;
use http_body::Body;
use std::fmt::Write;
use std::io::Read;
fn header_value_as_checksum_string(header_value: &http::HeaderValue) -> String {
let decoded_checksum = base64::decode(header_value.to_str().unwrap()).unwrap();
let decoded_checksum = decoded_checksum
.into_iter()
.map(|byte| format!("{:02X?}", byte))
.collect::<String>();
.fold(String::new(), |mut acc, byte| {
write!(acc, "{byte:02X?}").expect("string will always be writeable");
acc
});
format!("0x{}", decoded_checksum)
}

View File

@ -304,6 +304,7 @@ mod tests {
use aws_smithy_types::base64;
use http::HeaderValue;
use pretty_assertions::assert_eq;
use std::fmt::Write;
const TEST_DATA: &str = r#"test data"#;
@ -311,8 +312,10 @@ mod tests {
let decoded_checksum = base64::decode(header_value.to_str().unwrap()).unwrap();
let decoded_checksum = decoded_checksum
.into_iter()
.map(|byte| format!("{:02X?}", byte))
.collect::<String>();
.fold(String::new(), |mut acc, byte| {
write!(acc, "{byte:02X?}").expect("string will always be writeable");
acc
});
format!("0x{}", decoded_checksum)
}

View File

@ -499,9 +499,7 @@ event_loop.add_signal_handler(signal.SIGINT,
}
fn addr_incoming_from_socket(socket: Socket) -> AddrIncoming {
let std_listener: StdTcpListener = socket
.try_into()
.expect("unable to convert `socket2::Socket` into `std::net::TcpListener`");
let std_listener: StdTcpListener = socket.into();
// StdTcpListener::from_std doesn't set O_NONBLOCK
std_listener
.set_nonblocking(true)

View File

@ -110,10 +110,7 @@ impl<S> FromIterator<(String, S)> for AwsJsonRouter<S> {
#[inline]
fn from_iter<T: IntoIterator<Item = (String, S)>>(iter: T) -> Self {
Self {
routes: iter
.into_iter()
.map(|(svc, request_spec)| (svc, request_spec))
.collect(),
routes: iter.into_iter().collect(),
}
}
}

View File

@ -95,10 +95,7 @@ where
impl<S> FromIterator<(RequestSpec, S)> for RestRouter<S> {
#[inline]
fn from_iter<T: IntoIterator<Item = (RequestSpec, S)>>(iter: T) -> Self {
let mut routes: Vec<(RequestSpec, S)> = iter
.into_iter()
.map(|(request_spec, svc)| (request_spec, svc))
.collect();
let mut routes: Vec<(RequestSpec, S)> = iter.into_iter().collect();
// Sort them once by specificity, with the more specific routes sorted before the less
// specific ones, so that when routing a request we can simply iterate through the routes
@ -167,10 +164,7 @@ mod tests {
];
// Test both RestJson1 and RestXml routers.
let router: RestRouter<_> = request_specs
.into_iter()
.map(|(spec, svc_name)| (spec, svc_name))
.collect();
let router: RestRouter<_> = request_specs.into_iter().collect();
let hits = vec![
("A", Method::GET, "/a/b/c"),
@ -255,10 +249,7 @@ mod tests {
),
];
let router: RestRouter<_> = request_specs
.into_iter()
.map(|(spec, svc_name)| (spec, svc_name))
.collect();
let router: RestRouter<_> = request_specs.into_iter().collect();
let hits = vec![
("A1", Method::GET, "/a/foo"),

View File

@ -176,10 +176,7 @@ fn read_codepoint(rest: &[u8]) -> Result<u16, EscapeError> {
std::str::from_utf8(&rest[2..6]).map_err(|_| EscapeErrorKind::InvalidUtf8)?;
// Error on characters `u16::from_str_radix` would otherwise accept, such as `+`
if codepoint_str
.bytes()
.any(|byte| !matches!(byte, b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F'))
{
if codepoint_str.bytes().any(|byte| !byte.is_ascii_hexdigit()) {
return Err(EscapeErrorKind::InvalidUnicodeEscape(codepoint_str.into()).into());
}
Ok(u16::from_str_radix(codepoint_str, 16).expect("hex string is valid 16-bit value"))

View File

@ -1,6 +1,6 @@
[package]
name = "aws-smithy-mocks-experimental"
version = "0.1.0"
version = "0.1.1"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
description = "Experimental testing utilities for smithy-rs generated clients"
edition = "2021"

View File

@ -16,7 +16,7 @@ use aws_smithy_types::error::ErrorMetadata;
use aws_smithy_mocks_experimental::{mock, MockResponseInterceptor};
const S3_NO_SUCH_KEY: &'static str = r#"<?xml version="1.0" encoding="UTF-8"?>
const S3_NO_SUCH_KEY: &str = r#"<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NoSuchKey</Code>
<Message>The resource you requested does not exist</Message>

View File

@ -140,7 +140,7 @@ impl ThroughputLogs {
.iter()
.last()?
.0
.duration_since(self.inner.get(0)?.0)
.duration_since(self.inner.front()?.0)
.ok()?;
// during a "healthy" request we'll only have a few milliseconds of logs (shorter than the check window)
if total_length < time_window {