From 6df5fbd17ca28fba4776e28b280943db0460fd39 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:28:38 +0100 Subject: [PATCH 01/45] Run clippy --fix for Rust 1.62.0 and format the resulting code --- aws/rust-runtime/aws-endpoint/src/lib.rs | 6 ++---- .../aws-http/src/content_encoding.rs | 6 +++--- .../aws-http/src/recursion_detection.rs | 2 +- aws/rust-runtime/aws-http/src/retry.rs | 6 ++---- .../aws-inlineable/src/http_body_checksum.rs | 2 +- .../tests/middleware_e2e_test.rs | 2 +- .../src/http_request/canonical_request.rs | 2 +- .../aws-smithy-async/src/future/fn_stream.rs | 2 +- .../aws-smithy-eventstream/src/frame.rs | 4 ++-- .../aws-smithy-eventstream/src/str_bytes.rs | 2 +- .../instrumentation/sensitivity/sensitive.rs | 4 ++-- .../instrumentation/sensitivity/uri/label.rs | 10 +++++----- .../instrumentation/sensitivity/uri/query.rs | 10 +++++----- .../aws-smithy-http-server/src/protocols.rs | 2 +- .../aws-smithy-http-server/src/routing/mod.rs | 2 +- .../src/routing/tiny_map.rs | 6 +++--- rust-runtime/aws-smithy-http/src/header.rs | 18 ++++++------------ rust-runtime/aws-smithy-http/src/retry.rs | 6 ++---- .../aws-smithy-json/src/deserialize/token.rs | 2 +- .../aws-smithy-protocol-test/src/lib.rs | 4 +--- .../aws-smithy-types/src/date_time/format.rs | 2 +- rust-runtime/aws-smithy-xml/src/decode.rs | 4 ++-- rust-runtime/aws-smithy-xml/src/unescape.rs | 2 +- 23 files changed, 46 insertions(+), 60 deletions(-) diff --git a/aws/rust-runtime/aws-endpoint/src/lib.rs b/aws/rust-runtime/aws-endpoint/src/lib.rs index ab3e954911..fbf81a7fea 100644 --- a/aws/rust-runtime/aws-endpoint/src/lib.rs +++ b/aws/rust-runtime/aws-endpoint/src/lib.rs @@ -283,8 +283,7 @@ mod test { props.insert(region.clone()); props.insert(SigningService::from_static("qldb")); props.insert( - EndpointShim::from_arc(provider) - .resolve_endpoint(&Params::new(Some(region.clone()))), + EndpointShim::from_arc(provider).resolve_endpoint(&Params::new(Some(region))), ); }; let req = AwsEndpointStage.apply(req).expect("should succeed"); @@ -314,8 +313,7 @@ mod test { props.insert(region.clone()); props.insert(SigningService::from_static("qldb")); props.insert( - EndpointShim::from_arc(provider) - .resolve_endpoint(&Params::new(Some(region.clone()))), + EndpointShim::from_arc(provider).resolve_endpoint(&Params::new(Some(region))), ); }; let req = AwsEndpointStage.apply(req).expect("should succeed"); diff --git a/aws/rust-runtime/aws-http/src/content_encoding.rs b/aws/rust-runtime/aws-http/src/content_encoding.rs index e25b2c8b5c..bb66963ab9 100644 --- a/aws/rust-runtime/aws-http/src/content_encoding.rs +++ b/aws/rust-runtime/aws-http/src/content_encoding.rs @@ -376,7 +376,7 @@ mod tests { impl SputteringBody { fn len(&self) -> usize { - self.parts.iter().flat_map(|b| b).map(|b| b.len()).sum() + self.parts.iter().flatten().map(|b| b.len()).sum() } } @@ -462,7 +462,7 @@ mod tests { }; let timeout_duration = Duration::from_secs(3); - if let Err(_) = tokio::time::timeout(timeout_duration, test_fut).await { + if (tokio::time::timeout(timeout_duration, test_fut).await).is_err() { panic!("test_aws_chunked_encoding timed out after {timeout_duration:?}"); } } @@ -513,7 +513,7 @@ mod tests { }; let timeout_duration = Duration::from_secs(3); - if let Err(_) = tokio::time::timeout(timeout_duration, test_fut).await { + if (tokio::time::timeout(timeout_duration, test_fut).await).is_err() { panic!( "test_aws_chunked_encoding_sputtering_body timed out after {timeout_duration:?}" ); diff --git a/aws/rust-runtime/aws-http/src/recursion_detection.rs b/aws/rust-runtime/aws-http/src/recursion_detection.rs index 37805a534e..5e849598b4 100644 --- a/aws/rust-runtime/aws-http/src/recursion_detection.rs +++ b/aws/rust-runtime/aws-http/src/recursion_detection.rs @@ -160,7 +160,7 @@ mod test { ) } assert_ok(validate_headers( - &augmented_req.http().headers(), + augmented_req.http().headers(), test_case.request_headers_after(), )) } diff --git a/aws/rust-runtime/aws-http/src/retry.rs b/aws/rust-runtime/aws-http/src/retry.rs index 4ee9a3c792..0ce9d368f8 100644 --- a/aws/rust-runtime/aws-http/src/retry.rs +++ b/aws/rust-runtime/aws-http/src/retry.rs @@ -143,7 +143,7 @@ mod test { ) -> Result, SdkError> { Err(SdkError::ServiceError { err, - raw: operation::Response::new(raw.map(|b| SdkBody::from(b))), + raw: operation::Response::new(raw.map(SdkBody::from)), }) } @@ -265,9 +265,7 @@ mod test { policy.classify_retry( Result::, SdkError>::Err(SdkError::ResponseError { err: Box::new(UnmodeledError), - raw: operation::Response::new( - http::Response::new("OK").map(|b| SdkBody::from(b)) - ), + raw: operation::Response::new(http::Response::new("OK").map(SdkBody::from)), }) .as_ref() ), diff --git a/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs b/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs index 4848f5c89a..24679851fb 100644 --- a/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs +++ b/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs @@ -265,7 +265,7 @@ mod tests { for i in 0..10000 { let line = format!("This is a large file created for testing purposes {}", i); file.as_file_mut().write(line.as_bytes()).unwrap(); - crc32c_checksum.update(&line.as_bytes()); + crc32c_checksum.update(line.as_bytes()); } let body = ByteStream::read_from() diff --git a/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs b/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs index e52667290b..cb4a3c66e8 100644 --- a/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs +++ b/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs @@ -93,7 +93,7 @@ fn test_operation() -> Operation().ok()); } - _ => panic!("Unexpected `MissingContentTypeReason`: {}", e.to_string()), + _ => panic!("Unexpected `MissingContentTypeReason`: {}", e), }, } } diff --git a/rust-runtime/aws-smithy-http-server/src/routing/mod.rs b/rust-runtime/aws-smithy-http-server/src/routing/mod.rs index e72f04f30d..ec6b4394a6 100644 --- a/rust-runtime/aws-smithy-http-server/src/routing/mod.rs +++ b/rust-runtime/aws-smithy-http-server/src/routing/mod.rs @@ -323,7 +323,7 @@ mod rest_tests { #[inline] fn call(&mut self, req: Request) -> Self::Future { - let body = boxed(Body::from(format!("{} :: {}", self.0, req.uri().to_string()))); + let body = boxed(Body::from(format!("{} :: {}", self.0, req.uri()))); let fut = async { Ok(Response::builder().status(&http::StatusCode::OK).body(body).unwrap()) }; Box::pin(fut) } diff --git a/rust-runtime/aws-smithy-http-server/src/routing/tiny_map.rs b/rust-runtime/aws-smithy-http-server/src/routing/tiny_map.rs index 625bd2d4f6..236da27797 100644 --- a/rust-runtime/aws-smithy-http-server/src/routing/tiny_map.rs +++ b/rust-runtime/aws-smithy-http-server/src/routing/tiny_map.rs @@ -122,9 +122,9 @@ mod tests { const CUTOFF: usize = 5; - const SMALL_VALUES: [(&'static str, usize); 3] = [("a", 0), ("b", 1), ("c", 2)]; - const MEDIUM_VALUES: [(&'static str, usize); 5] = [("a", 0), ("b", 1), ("c", 2), ("d", 3), ("e", 4)]; - const LARGE_VALUES: [(&'static str, usize); 10] = [ + const SMALL_VALUES: [(&str, usize); 3] = [("a", 0), ("b", 1), ("c", 2)]; + const MEDIUM_VALUES: [(&str, usize); 5] = [("a", 0), ("b", 1), ("c", 2), ("d", 3), ("e", 4)]; + const LARGE_VALUES: [(&str, usize); 10] = [ ("a", 0), ("b", 1), ("c", 2), diff --git a/rust-runtime/aws-smithy-http/src/header.rs b/rust-runtime/aws-smithy-http/src/header.rs index 965bcdd8e0..69ef14ea47 100644 --- a/rust-runtime/aws-smithy-http/src/header.rs +++ b/rust-runtime/aws-smithy-http/src/header.rs @@ -604,10 +604,8 @@ mod test { let merged_header_map = append_merge_header_maps(left_hand_side_headers, right_hand_side_headers); - let actual_merged_values: Vec<_> = merged_header_map - .get_all(header_name.clone()) - .into_iter() - .collect(); + let actual_merged_values: Vec<_> = + merged_header_map.get_all(header_name).into_iter().collect(); let expected_merged_values = vec![left_header_value, right_header_value]; @@ -630,10 +628,8 @@ mod test { let merged_header_map = append_merge_header_maps(left_hand_side_headers, right_hand_side_headers); - let actual_merged_values: Vec<_> = merged_header_map - .get_all(header_name.clone()) - .into_iter() - .collect(); + let actual_merged_values: Vec<_> = + merged_header_map.get_all(header_name).into_iter().collect(); let expected_merged_values = vec![left_header_value_1, left_header_value_2, right_header_value]; @@ -655,10 +651,8 @@ mod test { let merged_header_map = append_merge_header_maps(left_hand_side_headers, right_hand_side_headers); - let actual_merged_values: Vec<_> = merged_header_map - .get_all(header_name.clone()) - .into_iter() - .collect(); + let actual_merged_values: Vec<_> = + merged_header_map.get_all(header_name).into_iter().collect(); let expected_merged_values = vec![right_header_value_1, right_header_value_2]; diff --git a/rust-runtime/aws-smithy-http/src/retry.rs b/rust-runtime/aws-smithy-http/src/retry.rs index b562b66290..48e86894cb 100644 --- a/rust-runtime/aws-smithy-http/src/retry.rs +++ b/rust-runtime/aws-smithy-http/src/retry.rs @@ -124,7 +124,7 @@ mod test { ) -> Result, SdkError> { Err(SdkError::ServiceError { err, - raw: operation::Response::new(raw.map(|b| SdkBody::from(b))), + raw: operation::Response::new(raw.map(SdkBody::from)), }) } @@ -194,9 +194,7 @@ mod test { policy.classify_retry( Result::, SdkError>::Err(SdkError::ResponseError { err: Box::new(UnmodeledError), - raw: operation::Response::new( - http::Response::new("OK").map(|b| SdkBody::from(b)) - ), + raw: operation::Response::new(http::Response::new("OK").map(SdkBody::from)), }) .as_ref() ), diff --git a/rust-runtime/aws-smithy-json/src/deserialize/token.rs b/rust-runtime/aws-smithy-json/src/deserialize/token.rs index 6525651828..3bead63fad 100644 --- a/rust-runtime/aws-smithy-json/src/deserialize/token.rs +++ b/rust-runtime/aws-smithy-json/src/deserialize/token.rs @@ -600,7 +600,7 @@ pub mod test { Err(Error::new( ErrorReason::Custom(Cow::Owned(format!( "{} is not a valid epoch", - invalid.replace("-", "") + invalid.replace('-', "") ))), None, )), diff --git a/rust-runtime/aws-smithy-protocol-test/src/lib.rs b/rust-runtime/aws-smithy-protocol-test/src/lib.rs index 1825867efd..651459e00e 100644 --- a/rust-runtime/aws-smithy-protocol-test/src/lib.rs +++ b/rust-runtime/aws-smithy-protocol-test/src/lib.rs @@ -386,9 +386,7 @@ mod tests { fn test_validate_empty_query_string() { let request = Request::builder().uri("/foo").body(()).unwrap(); validate_query_string(&request, &[]).expect("no required params should pass"); - validate_query_string(&request, &["a"]) - .err() - .expect("no params provided"); + validate_query_string(&request, &["a"]).expect_err("no params provided"); } #[test] diff --git a/rust-runtime/aws-smithy-types/src/date_time/format.rs b/rust-runtime/aws-smithy-types/src/date_time/format.rs index dd5d72d1b3..560a16409e 100644 --- a/rust-runtime/aws-smithy-types/src/date_time/format.rs +++ b/rust-runtime/aws-smithy-types/src/date_time/format.rs @@ -532,7 +532,7 @@ mod tests { .smithy_format_value .as_ref() .expect("parse test cases should always have a formatted value"); - let actual = parse(&to_parse); + let actual = parse(to_parse); assert!( actual.is_ok(), diff --git a/rust-runtime/aws-smithy-xml/src/decode.rs b/rust-runtime/aws-smithy-xml/src/decode.rs index cd0c6ba635..29c876d01f 100644 --- a/rust-runtime/aws-smithy-xml/src/decode.rs +++ b/rust-runtime/aws-smithy-xml/src/decode.rs @@ -531,8 +531,8 @@ mod test { root.start_el().attributes, vec![Attr { name: Name { - prefix: "xsi".into(), - local: "type".into() + prefix: "xsi", + local: "type" }, value: "CanonicalUser".into() }] diff --git a/rust-runtime/aws-smithy-xml/src/unescape.rs b/rust-runtime/aws-smithy-xml/src/unescape.rs index 170530596d..3f779ebc0c 100644 --- a/rust-runtime/aws-smithy-xml/src/unescape.rs +++ b/rust-runtime/aws-smithy-xml/src/unescape.rs @@ -150,7 +150,7 @@ mod test { fn no_panics(s: String) { let unescaped = unescape(&s); // if the string needed to be escaped, we - if s.contains("&") { + if s.contains('&') { assert!( matches!(unescaped, Ok(Cow::Owned(_)) | Err(_)) ); From 292fbec0f009dd4789b063511d4722c91d1ac7c4 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:29:38 +0100 Subject: [PATCH 02/45] Run clippy --fix on all targets --- aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs b/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs index cb4a3c66e8..90fdc32373 100644 --- a/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs +++ b/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs @@ -82,7 +82,7 @@ fn test_operation() -> Operation Date: Fri, 7 Oct 2022 11:30:56 +0100 Subject: [PATCH 03/45] Run clippy --fix with all features enabled --- aws/rust-runtime/aws-sigv4/src/event_stream.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aws/rust-runtime/aws-sigv4/src/event_stream.rs b/aws/rust-runtime/aws-sigv4/src/event_stream.rs index 018aeb9743..d3891c438b 100644 --- a/aws/rust-runtime/aws-sigv4/src/event_stream.rs +++ b/aws/rust-runtime/aws-sigv4/src/event_stream.rs @@ -159,7 +159,7 @@ mod tests { security_token: None, region: "us-east-1", service_name: "testservice", - time: (UNIX_EPOCH + Duration::new(123_456_789_u64, 1234u32)).into(), + time: (UNIX_EPOCH + Duration::new(123_456_789_u64, 1234u32)), settings: (), }; @@ -197,7 +197,7 @@ mod tests { security_token: None, region: "us-east-1", service_name: "testservice", - time: (UNIX_EPOCH + Duration::new(123_456_789_u64, 1234u32)).into(), + time: (UNIX_EPOCH + Duration::new(123_456_789_u64, 1234u32)), settings: (), }; From 74fafd942dac8fb1da17d3f23af08c1f92df420a Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:42:52 +0100 Subject: [PATCH 04/45] Avoid extra allocation --- rust-runtime/aws-smithy-query/src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rust-runtime/aws-smithy-query/src/lib.rs b/rust-runtime/aws-smithy-query/src/lib.rs index f8065be16e..67c0d2ee1d 100644 --- a/rust-runtime/aws-smithy-query/src/lib.rs +++ b/rust-runtime/aws-smithy-query/src/lib.rs @@ -9,6 +9,7 @@ use aws_smithy_types::date_time::{DateTimeFormatError, Format}; use aws_smithy_types::primitive::Encoder; use aws_smithy_types::{DateTime, Number}; use std::borrow::Cow; +use std::fmt::Write; use urlencoding::encode; pub struct QueryWriter<'a> { @@ -62,14 +63,18 @@ impl<'a> QueryMapWriter<'a> { pub fn entry(&mut self, key: &str) -> QueryValueWriter { let entry = if self.flatten { "" } else { ".entry" }; - self.output.push_str(&format!( + write!( + &mut self.output, "&{}{}.{}.{}={}", self.prefix, entry, self.next_index, self.key_name, encode(key) - )); + ) + // The `Write` implementation for `String` is infallible, + // see https://doc.rust-lang.org/src/alloc/string.rs.html#2815 + .unwrap(); let value_name = format!( "{}{}.{}.{}", self.prefix, entry, self.next_index, self.value_name From 3a99ce4300a5ecc365e14d23799e1e6d8a79124c Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:43:11 +0100 Subject: [PATCH 05/45] Use more idiomatic assert --- rust-runtime/aws-smithy-xml/src/decode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-xml/src/decode.rs b/rust-runtime/aws-smithy-xml/src/decode.rs index 29c876d01f..936d4c3d32 100644 --- a/rust-runtime/aws-smithy-xml/src/decode.rs +++ b/rust-runtime/aws-smithy-xml/src/decode.rs @@ -463,7 +463,7 @@ mod test { let xml = r#""#; let mut doc = Document::new(xml); let mut scoped = doc.root_element().expect("valid doc"); - assert_eq!(scoped.start_el.closed, true); + assert!(scoped.start_el.closed); assert!(scoped.next_tag().is_none()) } From 37a51e38626969844857b03f8b1eb129470b14b6 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:43:19 +0100 Subject: [PATCH 06/45] Ignore noisy lint --- rust-runtime/aws-smithy-xml/tests/handwritten_parsers.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust-runtime/aws-smithy-xml/tests/handwritten_parsers.rs b/rust-runtime/aws-smithy-xml/tests/handwritten_parsers.rs index d8bedd9870..a58f0b3241 100644 --- a/rust-runtime/aws-smithy-xml/tests/handwritten_parsers.rs +++ b/rust-runtime/aws-smithy-xml/tests/handwritten_parsers.rs @@ -44,6 +44,7 @@ fn deserialize_xml_attribute(inp: &str) -> Result { let mut doc = Document::new(inp); let mut root = doc.root_element()?; #[allow(unused_assignments)] + #[allow(clippy::blacklisted_name)] let mut foo: Option = None; let mut bar: Option = None; foo = root.start_el().attr("foo").map(|attr| attr.to_string()); From 1f8565591b3a42f649c95cb2fae606560be8a0bb Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 11:59:28 +0100 Subject: [PATCH 07/45] Update pyo3 and pyo3-asyncio to 0.17.0 --- rust-runtime/aws-smithy-http-server-python/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-runtime/aws-smithy-http-server-python/Cargo.toml b/rust-runtime/aws-smithy-http-server-python/Cargo.toml index b77292c324..7c858770ef 100644 --- a/rust-runtime/aws-smithy-http-server-python/Cargo.toml +++ b/rust-runtime/aws-smithy-http-server-python/Cargo.toml @@ -25,8 +25,8 @@ hyper = { version = "0.14.20", features = ["server", "http1", "http2", "tcp", "s num_cpus = "1.13.1" parking_lot = "0.12.1" pin-project-lite = "0.2" -pyo3 = "0.16.5" -pyo3-asyncio = { version = "0.16.0", features = ["tokio-runtime"] } +pyo3 = "0.17.0" +pyo3-asyncio = { version = "0.17.0", features = ["tokio-runtime"] } signal-hook = { version = "0.3.14", features = ["extended-siginfo"] } socket2 = { version = "0.4.4", features = ["all"] } thiserror = "1.0.32" From 5da170405e12d5077f67b8f8e41c2319138244d4 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:02:12 +0100 Subject: [PATCH 08/45] Implement Eq on aws-smithy-checksums::Error --- rust-runtime/aws-smithy-checksums/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-checksums/src/lib.rs b/rust-runtime/aws-smithy-checksums/src/lib.rs index 98ed65d34c..3c652258cd 100644 --- a/rust-runtime/aws-smithy-checksums/src/lib.rs +++ b/rust-runtime/aws-smithy-checksums/src/lib.rs @@ -82,7 +82,7 @@ impl ChecksumAlgorithm { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Error { UnknownChecksumAlgorithm(String), } From 5faf18d3050146dec85e70e6062b423d4d7583ca Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:02:53 +0100 Subject: [PATCH 09/45] Implement Eq on Protocol --- rust-runtime/aws-smithy-http-server/src/protocols.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-http-server/src/protocols.rs b/rust-runtime/aws-smithy-http-server/src/protocols.rs index 490df878be..35304ac201 100644 --- a/rust-runtime/aws-smithy-http-server/src/protocols.rs +++ b/rust-runtime/aws-smithy-http-server/src/protocols.rs @@ -8,7 +8,7 @@ use crate::rejection::MissingContentTypeReason; use crate::request::RequestParts; /// Supported protocols. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Protocol { RestJson1, RestXml, From aaf14f33eeee6ac97e53e1368355bccb71124a53 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:04:55 +0100 Subject: [PATCH 10/45] Replace conditionals with range-containment --- rust-runtime/aws-smithy-types/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-runtime/aws-smithy-types/src/lib.rs b/rust-runtime/aws-smithy-types/src/lib.rs index 3e7b599e15..6a18c187a0 100644 --- a/rust-runtime/aws-smithy-types/src/lib.rs +++ b/rust-runtime/aws-smithy-types/src/lib.rs @@ -291,7 +291,7 @@ impl TryFrom for f64 { } } Number::NegInt(v) => { - if -(1 << 53) <= v && v <= (1 << 53) { + if (-(1 << 53)..=(1 << 53)).contains(&v) { Ok(v as Self) } else { Err(Self::Error::I64ToFloatLossyConversion(v)) @@ -316,7 +316,7 @@ impl TryFrom for f32 { } } Number::NegInt(v) => { - if -(1 << 24) <= v && v <= (1 << 24) { + if (-(1 << 24)..=(1 << 24)).contains(&v) { Ok(v as Self) } else { Err(Self::Error::I64ToFloatLossyConversion(v)) From c45a6b5a56d391923efce3c884291c330218982d Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:07:28 +0100 Subject: [PATCH 11/45] Implement Eq on types in aws-smithy-types --- rust-runtime/aws-smithy-types/src/date_time/mod.rs | 2 +- rust-runtime/aws-smithy-types/src/lib.rs | 2 +- rust-runtime/aws-smithy-types/src/retry.rs | 4 ++-- rust-runtime/aws-smithy-types/src/timeout/config.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rust-runtime/aws-smithy-types/src/date_time/mod.rs b/rust-runtime/aws-smithy-types/src/date_time/mod.rs index bb1120c829..370cbad10c 100644 --- a/rust-runtime/aws-smithy-types/src/date_time/mod.rs +++ b/rust-runtime/aws-smithy-types/src/date_time/mod.rs @@ -46,7 +46,7 @@ const NANOS_PER_SECOND_U32: u32 = 1_000_000_000; /// The [`aws-smithy-types-convert`](https://crates.io/crates/aws-smithy-types-convert) crate /// can be used for conversions to/from other libraries, such as /// [`time`](https://crates.io/crates/time) or [`chrono`](https://crates.io/crates/chrono). -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct DateTime { seconds: i64, subsecond_nanos: u32, diff --git a/rust-runtime/aws-smithy-types/src/lib.rs b/rust-runtime/aws-smithy-types/src/lib.rs index 6a18c187a0..f88b7b2b03 100644 --- a/rust-runtime/aws-smithy-types/src/lib.rs +++ b/rust-runtime/aws-smithy-types/src/lib.rs @@ -27,7 +27,7 @@ pub use crate::date_time::DateTime; /// Binary Blob Type /// /// Blobs represent protocol-agnostic binary content. -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct Blob { inner: Vec, } diff --git a/rust-runtime/aws-smithy-types/src/retry.rs b/rust-runtime/aws-smithy-types/src/retry.rs index 56556154bb..7bfe0bdfd4 100644 --- a/rust-runtime/aws-smithy-types/src/retry.rs +++ b/rust-runtime/aws-smithy-types/src/retry.rs @@ -130,7 +130,7 @@ impl FromStr for RetryMode { /// Builder for [`RetryConfig`]. #[non_exhaustive] -#[derive(Debug, Default, Clone, PartialEq)] +#[derive(Debug, Default, Clone, PartialEq, Eq)] pub struct RetryConfigBuilder { mode: Option, max_attempts: Option, @@ -217,7 +217,7 @@ impl RetryConfigBuilder { /// Retry configuration for requests. #[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct RetryConfig { mode: RetryMode, max_attempts: u32, diff --git a/rust-runtime/aws-smithy-types/src/timeout/config.rs b/rust-runtime/aws-smithy-types/src/timeout/config.rs index 68d1296695..a815dacd40 100644 --- a/rust-runtime/aws-smithy-types/src/timeout/config.rs +++ b/rust-runtime/aws-smithy-types/src/timeout/config.rs @@ -197,7 +197,7 @@ impl From for TimeoutConfigBuilder { /// # } /// ``` #[non_exhaustive] -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub struct TimeoutConfig { connect_timeout: Option, read_timeout: Option, @@ -274,7 +274,7 @@ impl TimeoutConfig { /// Configuration subset of [`TimeoutConfig`] for operation timeouts #[non_exhaustive] -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub struct OperationTimeoutConfig { operation_timeout: Option, operation_attempt_timeout: Option, From f2cd9018844130d441820742dc1cf1c7abeaa38b Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:08:26 +0100 Subject: [PATCH 12/45] Implement Eq on types in aws-smithy-http-server-python --- rust-runtime/aws-smithy-http-server-python/src/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-runtime/aws-smithy-http-server-python/src/types.rs b/rust-runtime/aws-smithy-http-server-python/src/types.rs index 98adbd4119..48dc0a6926 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/types.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/types.rs @@ -26,7 +26,7 @@ use crate::PyError; /// Python Wrapper for [aws_smithy_types::Blob]. #[pyclass] -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Blob(aws_smithy_types::Blob); impl Blob { @@ -88,7 +88,7 @@ impl<'blob> From<&'blob Blob> for &'blob aws_smithy_types::Blob { /// Python Wrapper for [aws_smithy_types::date_time::DateTime]. #[pyclass] -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct DateTime(aws_smithy_types::date_time::DateTime); #[pyclass] From 78f4b07344d2cbb9d06b30ffd9bad16031fdd83b Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:09:05 +0100 Subject: [PATCH 13/45] Implement Eq on types in aws-smithy-eventstream --- rust-runtime/aws-smithy-eventstream/src/frame.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-eventstream/src/frame.rs b/rust-runtime/aws-smithy-eventstream/src/frame.rs index dbe0a638a3..2be5c688b0 100644 --- a/rust-runtime/aws-smithy-eventstream/src/frame.rs +++ b/rust-runtime/aws-smithy-eventstream/src/frame.rs @@ -96,7 +96,7 @@ mod value { /// Event Stream frame header value. #[non_exhaustive] - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug, PartialEq, Eq)] pub enum HeaderValue { Bool(bool), Byte(i8), From 590f01af7326bde7de97cae97feeedf593b9239b Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:09:47 +0100 Subject: [PATCH 14/45] Implement Eq on types in aws-smithy-xml --- rust-runtime/aws-smithy-eventstream/src/frame.rs | 4 ++-- rust-runtime/aws-smithy-xml/src/decode.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rust-runtime/aws-smithy-eventstream/src/frame.rs b/rust-runtime/aws-smithy-eventstream/src/frame.rs index 2be5c688b0..ad9d3d9e14 100644 --- a/rust-runtime/aws-smithy-eventstream/src/frame.rs +++ b/rust-runtime/aws-smithy-eventstream/src/frame.rs @@ -300,7 +300,7 @@ pub use value::HeaderValue; /// Event Stream header. #[non_exhaustive] -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "derive-arbitrary", derive(arbitrary::Arbitrary))] pub struct Header { name: StrBytes, @@ -368,7 +368,7 @@ pub fn write_headers_to(headers: &[Header], mut buffer: B) -> Result< /// Event Stream message. #[non_exhaustive] -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Message { headers: Vec
, payload: Bytes, diff --git a/rust-runtime/aws-smithy-xml/src/decode.rs b/rust-runtime/aws-smithy-xml/src/decode.rs index 936d4c3d32..f4ee499e3d 100644 --- a/rust-runtime/aws-smithy-xml/src/decode.rs +++ b/rust-runtime/aws-smithy-xml/src/decode.rs @@ -51,7 +51,7 @@ impl XmlError { } } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct Name<'a> { pub prefix: &'a str, pub local: &'a str, @@ -72,14 +72,14 @@ impl Name<'_> { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct Attr<'a> { name: Name<'a>, // attribute values can be escaped (e.g. with double quotes, so we need a Cow) value: Cow<'a, str>, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct StartEl<'a> { name: Name<'a>, attributes: Vec>, From d78bb62124c4b3a24a35bdd655995de11252d17f Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:13:08 +0100 Subject: [PATCH 15/45] Implement Eq on aws-sigv4 --- aws/rust-runtime/aws-sigv4/src/http_request/settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/rust-runtime/aws-sigv4/src/http_request/settings.rs b/aws/rust-runtime/aws-sigv4/src/http_request/settings.rs index e78ef7d4a9..890ba5b362 100644 --- a/aws/rust-runtime/aws-sigv4/src/http_request/settings.rs +++ b/aws/rust-runtime/aws-sigv4/src/http_request/settings.rs @@ -10,7 +10,7 @@ use std::time::Duration; pub type SigningParams<'a> = crate::SigningParams<'a, SigningSettings>; /// HTTP-specific signing settings -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] #[non_exhaustive] pub struct SigningSettings { /// Specifies how to encode the request URL when signing. Some services do not decode From 3da634ab22d97e1cd5da8732e3a65a42cb601b51 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:15:50 +0100 Subject: [PATCH 16/45] Update CI to use Rust 1.62.0 --- .github/workflows/ci.yml | 2 +- .github/workflows/pull-request-bot.yml | 2 +- .github/workflows/release.yml | 2 +- gradle.properties | 2 +- tools/Dockerfile | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4ab973ea7..8b412e36bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: workflow_call: env: - rust_version: 1.61.0 + rust_version: 1.62.0 rust_toolchain_components: clippy,rustfmt jobs: diff --git a/.github/workflows/pull-request-bot.yml b/.github/workflows/pull-request-bot.yml index 2e9125340b..75f294e91c 100644 --- a/.github/workflows/pull-request-bot.yml +++ b/.github/workflows/pull-request-bot.yml @@ -28,7 +28,7 @@ concurrency: env: java_version: 11 - rust_version: 1.61.0 + rust_version: 1.62.0 rust_toolchain_components: clippy,rustfmt apt_dependencies: libssl-dev gnuplot jq diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d13df296ed..ae1c861890 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ concurrency: cancel-in-progress: true env: - rust_version: 1.61.0 + rust_version: 1.62.0 name: Release smithy-rs on: diff --git a/gradle.properties b/gradle.properties index ec1cba2686..73ede4c662 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ # # Rust MSRV (entered into the generated README) -rust.msrv=1.61.0 +rust.msrv=1.62.0 org.gradle.jvmargs=-Xmx1024M diff --git a/tools/Dockerfile b/tools/Dockerfile index 1e61c92387..3cf7881cb9 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -45,7 +45,7 @@ RUN set -eux; \ # Rust & Tools Installation Stage # FROM bare_base_image AS install_rust -ARG rust_stable_version=1.61.0 +ARG rust_stable_version=1.62.0 ARG rust_nightly_version=nightly-2022-07-25 ARG cargo_deny_version=0.12.2 ARG cargo_udeps_version=0.1.29 @@ -116,7 +116,7 @@ RUN set -eux; \ # Final image # FROM bare_base_image AS final_image -ARG rust_stable_version=1.61.0 +ARG rust_stable_version=1.62.0 ARG rust_nightly_version=nightly-2022-07-25 RUN set -eux; \ yum -y updateinfo; \ From 5169bd95aa4dbbfc77c23bf7415e98ebc6361733 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:37:11 +0100 Subject: [PATCH 17/45] Add Eq for generated types that implement PartialEq --- .../codegen/client/smithy/StreamingTraitSymbolProvider.kt | 4 ++-- .../amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt | 1 + .../smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt | 2 +- .../rust/codegen/core/smithy/generators/BuilderGenerator.kt | 2 +- .../server/python/smithy/PythonServerSymbolProvider.kt | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt index cd362acccf..3b0c090e9b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt @@ -74,14 +74,14 @@ class StreamingShapeMetadataProvider( override fun structureMeta(structureShape: StructureShape): RustMetadata { val baseMetadata = base.toSymbol(structureShape).expectRustMetadata() return if (structureShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq) + baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq, RuntimeType.Eq) } else baseMetadata } override fun unionMeta(unionShape: UnionShape): RustMetadata { val baseMetadata = base.toSymbol(unionShape).expectRustMetadata() return if (unionShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq) + baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq, RuntimeType.Eq) } else baseMetadata } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt index 781014bd85..e67d1cf460 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt @@ -198,6 +198,7 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n val From = RuntimeType("From", dependency = null, namespace = "std::convert") val TryFrom = RuntimeType("TryFrom", dependency = null, namespace = "std::convert") val PartialEq = std.member("cmp::PartialEq") + val Eq = std.member("cmp::Eq") val StdError = RuntimeType("Error", dependency = null, namespace = "std::error") val String = RuntimeType("String", dependency = null, namespace = "std::string") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt index 8c5a56b577..4781c44b52 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt @@ -131,7 +131,7 @@ class BaseSymbolMetadataProvider( companion object { private val defaultDerives by lazy { with(RuntimeType) { - listOf(Debug, PartialEq, Clone) + listOf(Debug, PartialEq, Eq, Clone) } } } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt index c561b04c39..7d77a00b46 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt @@ -160,7 +160,7 @@ class BuilderGenerator( writer.docs("A builder for #D.", structureSymbol) // Matching derives to the main structure + `Default` since we are a builder and everything is optional. val baseDerives = structureSymbol.expectRustMetadata().derives - val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone)) + RuntimeType.Default + val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Eq, RuntimeType.Clone)) + RuntimeType.Default baseDerives.copy(derives = derives).render(writer) writer.rustBlock("pub struct $builderName") { for (member in members) { diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt index 1e6f2b7ea8..dc9ca9f153 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt @@ -95,14 +95,14 @@ class PythonStreamingShapeMetadataProvider(private val base: RustSymbolProvider, override fun structureMeta(structureShape: StructureShape): RustMetadata { val baseMetadata = base.toSymbol(structureShape).expectRustMetadata() return if (structureShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.PartialEq) + baseMetadata.withoutDerives(RuntimeType.PartialEq, RuntimeType.Eq) } else baseMetadata } override fun unionMeta(unionShape: UnionShape): RustMetadata { val baseMetadata = base.toSymbol(unionShape).expectRustMetadata() return if (unionShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.PartialEq) + baseMetadata.withoutDerives(RuntimeType.PartialEq, RuntimeType.Eq) } else baseMetadata } From 1d27e8f358c7ef80bc7bd27c6d7cd6cf4c4756a1 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:41:51 +0100 Subject: [PATCH 18/45] Allow clippy::needless_return in generated code --- .../client/smithy/customizations/AllowLintsGenerator.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt index f96b21336e..cb83d78d36 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt @@ -39,6 +39,9 @@ val AllowedClippyLints = listOf( // Some models have shapes that generate complex Rust types (e.g. nested collection and map shapes). "type_complexity", + + // Determining if the expression is the last one (to remove return) can make codegen harder in some cases. + "needless_return" ) val AllowedRustdocLints = listOf( From fc69639fd1e655f2bd5edfddc79a575ead2ab972 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:46:59 +0100 Subject: [PATCH 19/45] Remove unnecessary reborrow in http_serde --- .../codegen/core/smithy/generators/http/HttpBindingGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index e76ed60ac9..398af78313 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -490,7 +490,7 @@ class HttpBindingGenerator( rustTemplate( """ let header_value = $safeName; - let header_value = http::header::HeaderValue::try_from(&*header_value).map_err(|err| { + let header_value = http::header::HeaderValue::try_from(header_value).map_err(|err| { #{build_error}::InvalidField { field: "$memberName", details: format!("`{}` cannot be used as a header value: {}", &${ memberShape.redactIfNecessary(model, "header_value") }, err)} From 90be70c7d14a9df39de01fb8f67f94b98f0772d5 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:48:53 +0100 Subject: [PATCH 20/45] Remove unnecessary borrow in operation_deser --- .../client/smithy/protocols/HttpBoundProtocolGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt index 55e4fe5182..f461f957cb 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt @@ -219,7 +219,7 @@ class HttpBoundProtocolTraitImplGenerator( if (errorShape.errorMessageMember() != null) { rust( """ - if (&tmp.message).is_none() { + if tmp.message.is_none() { tmp.message = _error_message; } """, From dbd6bc634198595155b3422c3d2e8ce3479ac610 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 12:58:47 +0100 Subject: [PATCH 21/45] Add CHANGELOG entries --- CHANGELOG.next.toml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 02caa3a350..df004e4eff 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -11,6 +11,25 @@ # meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"} # author = "rcoh" + +[[smithy-rs]] +message = "Bump MSRV to be 1.62.0." +references = ["smithy-rs#1825"] +meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all" } +author = "LukeMathWalker" + +[[smithy-rs]] +message = "Bump pyo3 and pyo3-asyncio from 0.16.x to 0.17.0 for aws-smithy-http-server-python." +references = ["smithy-rs#1825"] +meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "server" } +author = "LukeMathWalker" + +[[aws-sdk-rust]] +message = "Bump MSRV to be 1.62.0." +references = ["smithy-rs#1825"] +meta = { "breaking" = true, "tada" = false, "bug" = false } +author = "LukeMathWalker" + [[smithy-rs]] message = """ Replace all usages of `AtomicU64` with `AtomicUsize` to support 32bit targets. From afe4afbc9a549fb226e4b10f1af5513f094b92b4 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 15:04:41 +0100 Subject: [PATCH 22/45] Revert "Add Eq for generated types that implement PartialEq" This reverts commit 5169bd95aa4dbbfc77c23bf7415e98ebc6361733. --- .../codegen/client/smithy/StreamingTraitSymbolProvider.kt | 4 ++-- .../amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt | 1 - .../smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt | 2 +- .../rust/codegen/core/smithy/generators/BuilderGenerator.kt | 2 +- .../server/python/smithy/PythonServerSymbolProvider.kt | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt index 3b0c090e9b..cd362acccf 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/StreamingTraitSymbolProvider.kt @@ -74,14 +74,14 @@ class StreamingShapeMetadataProvider( override fun structureMeta(structureShape: StructureShape): RustMetadata { val baseMetadata = base.toSymbol(structureShape).expectRustMetadata() return if (structureShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq, RuntimeType.Eq) + baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq) } else baseMetadata } override fun unionMeta(unionShape: UnionShape): RustMetadata { val baseMetadata = base.toSymbol(unionShape).expectRustMetadata() return if (unionShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq, RuntimeType.Eq) + baseMetadata.withoutDerives(RuntimeType.Clone, RuntimeType.PartialEq) } else baseMetadata } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt index e67d1cf460..781014bd85 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt @@ -198,7 +198,6 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n val From = RuntimeType("From", dependency = null, namespace = "std::convert") val TryFrom = RuntimeType("TryFrom", dependency = null, namespace = "std::convert") val PartialEq = std.member("cmp::PartialEq") - val Eq = std.member("cmp::Eq") val StdError = RuntimeType("Error", dependency = null, namespace = "std::error") val String = RuntimeType("String", dependency = null, namespace = "std::string") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt index 4781c44b52..8c5a56b577 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt @@ -131,7 +131,7 @@ class BaseSymbolMetadataProvider( companion object { private val defaultDerives by lazy { with(RuntimeType) { - listOf(Debug, PartialEq, Eq, Clone) + listOf(Debug, PartialEq, Clone) } } } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt index 7d77a00b46..c561b04c39 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt @@ -160,7 +160,7 @@ class BuilderGenerator( writer.docs("A builder for #D.", structureSymbol) // Matching derives to the main structure + `Default` since we are a builder and everything is optional. val baseDerives = structureSymbol.expectRustMetadata().derives - val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Eq, RuntimeType.Clone)) + RuntimeType.Default + val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone)) + RuntimeType.Default baseDerives.copy(derives = derives).render(writer) writer.rustBlock("pub struct $builderName") { for (member in members) { diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt index dc9ca9f153..1e6f2b7ea8 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt @@ -95,14 +95,14 @@ class PythonStreamingShapeMetadataProvider(private val base: RustSymbolProvider, override fun structureMeta(structureShape: StructureShape): RustMetadata { val baseMetadata = base.toSymbol(structureShape).expectRustMetadata() return if (structureShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.PartialEq, RuntimeType.Eq) + baseMetadata.withoutDerives(RuntimeType.PartialEq) } else baseMetadata } override fun unionMeta(unionShape: UnionShape): RustMetadata { val baseMetadata = base.toSymbol(unionShape).expectRustMetadata() return if (unionShape.hasStreamingMember(model)) { - baseMetadata.withoutDerives(RuntimeType.PartialEq, RuntimeType.Eq) + baseMetadata.withoutDerives(RuntimeType.PartialEq) } else baseMetadata } From 625c6d4c5e0a5fbbd319693285fabd0942f65717 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 15:11:14 +0100 Subject: [PATCH 23/45] Update pyo3 and pyo3-asyncio in generated code for python server --- codegen-core/common-test-models/pokemon-common.smithy | 4 +++- .../server/python/smithy/PythonServerCargoDependency.kt | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/codegen-core/common-test-models/pokemon-common.smithy b/codegen-core/common-test-models/pokemon-common.smithy index 3198cb8c74..d3f7bc5115 100644 --- a/codegen-core/common-test-models/pokemon-common.smithy +++ b/codegen-core/common-test-models/pokemon-common.smithy @@ -53,9 +53,11 @@ structure GetServerStatisticsInput { } structure GetServerStatisticsOutput { /// The number of calls executed by the server. @required - calls_count: Long, + calls_count: MyFloat, } +float MyFloat + list FlavorTextEntries { member: FlavorText } diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCargoDependency.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCargoDependency.kt index 6fd3b430c2..0957405454 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCargoDependency.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCargoDependency.kt @@ -15,8 +15,8 @@ import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig * For a dependency that is used in the client, or in both the client and the server, use [CargoDependency] directly. */ object PythonServerCargoDependency { - val PyO3: CargoDependency = CargoDependency("pyo3", CratesIo("0.16"), features = setOf("extension-module")) - val PyO3Asyncio: CargoDependency = CargoDependency("pyo3-asyncio", CratesIo("0.16"), features = setOf("attributes", "tokio-runtime")) + val PyO3: CargoDependency = CargoDependency("pyo3", CratesIo("0.17"), features = setOf("extension-module")) + val PyO3Asyncio: CargoDependency = CargoDependency("pyo3-asyncio", CratesIo("0.17"), features = setOf("attributes", "tokio-runtime")) val Tokio: CargoDependency = CargoDependency("tokio", CratesIo("1.20.1"), features = setOf("full")) val Tracing: CargoDependency = CargoDependency("tracing", CratesIo("0.1")) val Tower: CargoDependency = CargoDependency("tower", CratesIo("0.4")) From 068c63ca2030879584e7b602bd0648abab19cabe Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 15:43:29 +0100 Subject: [PATCH 24/45] Allow clippy::derive_partial_eq_without_eq on structs and builders --- .../smithy/rust/codegen/core/rustlang/RustType.kt | 1 + .../core/smithy/generators/BuilderGenerator.kt | 11 +++++++---- .../core/smithy/generators/StructureGenerator.kt | 9 +++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt index 24344b57c7..854fa430ed 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt @@ -387,6 +387,7 @@ sealed class Attribute { val AllowDeadCode = Custom("allow(dead_code)") val DocHidden = Custom("doc(hidden)") val DocInline = Custom("doc(inline)") + val DerivePartialEqWithoutEq = Custom("allow(clippy::derive_partial_eq_without_eq)") } data class Derives(val derives: Set) : Attribute() { diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt index c561b04c39..13f0df20b1 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt @@ -9,6 +9,7 @@ import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.StructureShape +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter @@ -159,10 +160,12 @@ class BuilderGenerator( writer.docs("A builder for #D.", structureSymbol) // Matching derives to the main structure + `Default` since we are a builder and everything is optional. - val baseDerives = structureSymbol.expectRustMetadata().derives - val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone)) + RuntimeType.Default - baseDerives.copy(derives = derives).render(writer) - writer.rustBlock("pub struct $builderName") { + val containerMeta = structureSymbol.expectRustMetadata() + val derives = containerMeta.derives.copy(derives = containerMeta.derives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone)) + RuntimeType.Default) + val additionalAttributes = containerMeta.additionalAttributes.toMutableList(); + additionalAttributes.add(Attribute.DerivePartialEqWithoutEq) + containerMeta.copy(derives = derives, additionalAttributes = additionalAttributes).render(writer) + writer.rustBlock("struct $builderName") { for (member in members) { val memberName = symbolProvider.toMemberName(member) // All fields in the builder are optional. diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt index 5bf6e0a6b8..7f2fa9ae84 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt @@ -24,6 +24,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.isDeref import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock +import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider @@ -160,10 +161,14 @@ open class StructureGenerator( writer.documentShape(shape, model) writer.deprecatedShape(shape) val withoutDebug = containerMeta.derives.copy(derives = containerMeta.derives.derives - RuntimeType.Debug) - containerMeta.copy(derives = withoutDebug).render(writer) + val additionalAttributes = containerMeta.additionalAttributes.toMutableList(); + additionalAttributes.add(Attribute.DerivePartialEqWithoutEq) + containerMeta.copy( + derives = withoutDebug, + additionalAttributes = additionalAttributes).render(writer) writer.rustBlock("struct $name ${lifetimeDeclaration()}") { - writer.forEachMember(members) { member, memberName, memberSymbol -> + writer.forEachMember(members) { member, memberName, memberSymbol -> renderStructureMember(writer, member, memberName, memberSymbol) } } From 316b031b7501cd886eac32c632ec4522a4a72e5c Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 15:49:49 +0100 Subject: [PATCH 25/45] Run clippy on tools --- tools/publisher/src/cargo/publish.rs | 6 +++--- tools/publisher/src/package.rs | 5 ++--- tools/publisher/src/sort.rs | 2 +- tools/publisher/src/subcommand/publish.rs | 6 +++--- tools/publisher/src/subcommand/tag_versions_manifest.rs | 2 +- tools/sdk-lints/src/copyright.rs | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tools/publisher/src/cargo/publish.rs b/tools/publisher/src/cargo/publish.rs index a8a08a6cdc..71e79e3814 100644 --- a/tools/publisher/src/cargo/publish.rs +++ b/tools/publisher/src/cargo/publish.rs @@ -71,7 +71,7 @@ mod tests { "aws-sdk-dynamodb", Version::parse("0.0.22-alpha").unwrap(), ), - package_path: env::current_dir().unwrap().into(), + package_path: env::current_dir().unwrap(), } .spawn() .await @@ -86,7 +86,7 @@ mod tests { "something", Version::parse("0.0.22-alpha").unwrap(), ), - package_path: env::current_dir().unwrap().into(), + package_path: env::current_dir().unwrap(), } .spawn() .await; @@ -108,7 +108,7 @@ mod tests { "aws-sdk-dynamodb", Version::parse("0.0.22-alpha").unwrap(), ), - package_path: env::current_dir().unwrap().into(), + package_path: env::current_dir().unwrap(), } .spawn() .await diff --git a/tools/publisher/src/package.rs b/tools/publisher/src/package.rs index 4777e0a8a3..2cc13df3ad 100644 --- a/tools/publisher/src/package.rs +++ b/tools/publisher/src/package.rs @@ -386,7 +386,7 @@ mod tests { let error = format!( "{}", - read_package(&path, manifest).err().expect("should fail") + read_package(&path, manifest).expect_err("should fail") ); assert!( error.contains("Invalid crate version"), @@ -517,8 +517,7 @@ mod tests { &[("C", "1.2.0"), ("D", "1.3.0"), ("F", "1.4.0")], ), ]) - .err() - .expect("fail"); + .expect_err("fail"); assert_eq!( "crate A has multiple versions: 1.1.0 and 1.0.0", format!("{}", error) diff --git a/tools/publisher/src/sort.rs b/tools/publisher/src/sort.rs index cff1d21ad5..a6da808a4e 100644 --- a/tools/publisher/src/sort.rs +++ b/tools/publisher/src/sort.rs @@ -120,7 +120,7 @@ mod tests { package("C", &["B"]), ]; - let error = dependency_order(packages).err().expect("cycle"); + let error = dependency_order(packages).expect_err("cycle"); assert_eq!("dependency cycle detected", format!("{}", error)); } diff --git a/tools/publisher/src/subcommand/publish.rs b/tools/publisher/src/subcommand/publish.rs index a2fdc171fb..58cc9ea833 100644 --- a/tools/publisher/src/subcommand/publish.rs +++ b/tools/publisher/src/subcommand/publish.rs @@ -126,7 +126,7 @@ async fn is_published(handle: &PackageHandle) -> Result { 3, Duration::from_secs(5), || async { - let expected_version = (&handle.version).to_string(); + let expected_version = handle.version.to_string(); let crate_info = match CRATES_IO_CLIENT.get_crate(&handle.name).await { Ok(info) => info, Err(Error::NotFound(_)) => return Ok(false), @@ -260,9 +260,9 @@ mod test { #[tokio::test] async fn crate_published_works() { let handle = PackageHandle::new("aws-smithy-http", "0.27.0-alpha.1".parse().unwrap()); - assert_eq!(is_published(&handle).await.expect("failed"), true); + assert!(is_published(&handle).await.expect("failed")); // we will never publish this version let handle = PackageHandle::new("aws-smithy-http", "0.21.0-alpha.1".parse().unwrap()); - assert_eq!(is_published(&handle).await.expect("failed"), false); + assert!(!is_published(&handle).await.expect("failed")); } } diff --git a/tools/publisher/src/subcommand/tag_versions_manifest.rs b/tools/publisher/src/subcommand/tag_versions_manifest.rs index dfc52c7f57..ebd05d9910 100644 --- a/tools/publisher/src/subcommand/tag_versions_manifest.rs +++ b/tools/publisher/src/subcommand/tag_versions_manifest.rs @@ -86,7 +86,7 @@ mod tests { .unwrap(); let expected = { - let mut expected = original.clone(); + let mut expected = original; expected.release.as_mut().unwrap().tag = Some("some-release-tag".to_string()); expected }; diff --git a/tools/sdk-lints/src/copyright.rs b/tools/sdk-lints/src/copyright.rs index 04b61a59ce..5645fb6590 100644 --- a/tools/sdk-lints/src/copyright.rs +++ b/tools/sdk-lints/src/copyright.rs @@ -55,7 +55,7 @@ fn check_copyright_header(path: impl AsRef) -> Vec { path.as_ref().display() ))]; } - return vec![]; + vec![] } fn needs_copyright_header(path: &Path) -> bool { From 34ef53540dd76f960fbd8e4174f4bc1451890a0f Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 16:27:22 +0100 Subject: [PATCH 26/45] Fix accidental move in generated code --- .../codegen/core/smithy/generators/http/HttpBindingGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index 398af78313..cdcab553a8 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -557,7 +557,7 @@ class HttpBindingGenerator( target.isStringShape -> { if (target.hasTrait()) { val func = writer.format(RuntimeType.Base64Encode(runtimeConfig)) - "$func(&$targetName)" + "&$func(&$targetName)" } else { quoteValue("AsRef::::as_ref($targetName)") } From 669e8ea095376fb74aa6d2389e78bdba38924bc9 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 16:27:56 +0100 Subject: [PATCH 27/45] Revert "Allow clippy::derive_partial_eq_without_eq on structs and builders" This reverts commit 068c63ca2030879584e7b602bd0648abab19cabe. --- .../smithy/rust/codegen/core/rustlang/RustType.kt | 1 - .../core/smithy/generators/BuilderGenerator.kt | 11 ++++------- .../core/smithy/generators/StructureGenerator.kt | 9 ++------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt index 854fa430ed..24344b57c7 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt @@ -387,7 +387,6 @@ sealed class Attribute { val AllowDeadCode = Custom("allow(dead_code)") val DocHidden = Custom("doc(hidden)") val DocInline = Custom("doc(inline)") - val DerivePartialEqWithoutEq = Custom("allow(clippy::derive_partial_eq_without_eq)") } data class Derives(val derives: Set) : Attribute() { diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt index 13f0df20b1..c561b04c39 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt @@ -9,7 +9,6 @@ import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.StructureShape -import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter @@ -160,12 +159,10 @@ class BuilderGenerator( writer.docs("A builder for #D.", structureSymbol) // Matching derives to the main structure + `Default` since we are a builder and everything is optional. - val containerMeta = structureSymbol.expectRustMetadata() - val derives = containerMeta.derives.copy(derives = containerMeta.derives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone)) + RuntimeType.Default) - val additionalAttributes = containerMeta.additionalAttributes.toMutableList(); - additionalAttributes.add(Attribute.DerivePartialEqWithoutEq) - containerMeta.copy(derives = derives, additionalAttributes = additionalAttributes).render(writer) - writer.rustBlock("struct $builderName") { + val baseDerives = structureSymbol.expectRustMetadata().derives + val derives = baseDerives.derives.intersect(setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone)) + RuntimeType.Default + baseDerives.copy(derives = derives).render(writer) + writer.rustBlock("pub struct $builderName") { for (member in members) { val memberName = symbolProvider.toMemberName(member) // All fields in the builder are optional. diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt index 7f2fa9ae84..5bf6e0a6b8 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt @@ -24,7 +24,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.isDeref import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock -import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustSymbolProvider @@ -161,14 +160,10 @@ open class StructureGenerator( writer.documentShape(shape, model) writer.deprecatedShape(shape) val withoutDebug = containerMeta.derives.copy(derives = containerMeta.derives.derives - RuntimeType.Debug) - val additionalAttributes = containerMeta.additionalAttributes.toMutableList(); - additionalAttributes.add(Attribute.DerivePartialEqWithoutEq) - containerMeta.copy( - derives = withoutDebug, - additionalAttributes = additionalAttributes).render(writer) + containerMeta.copy(derives = withoutDebug).render(writer) writer.rustBlock("struct $name ${lifetimeDeclaration()}") { - writer.forEachMember(members) { member, memberName, memberSymbol -> + writer.forEachMember(members) { member, memberName, memberSymbol -> renderStructureMember(writer, member, memberName, memberSymbol) } } From 38cfa85bebf743c3331a309218c0d7fa867d940c Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Fri, 7 Oct 2022 16:37:28 +0100 Subject: [PATCH 28/45] Fix another accidental move in generated code --- .../codegen/core/smithy/generators/http/HttpBindingGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index cdcab553a8..827d30e0b9 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -566,7 +566,7 @@ class HttpBindingGenerator( val timestampFormat = index.determineTimestampFormat(member, HttpBinding.Location.HEADER, defaultTimestampFormat) val timestampFormatType = RuntimeType.TimestampFormat(runtimeConfig, timestampFormat) - quoteValue("$targetName.fmt(${writer.format(timestampFormatType)})?") + quoteValue("&$targetName.fmt(${writer.format(timestampFormatType)})?") } target.isListShape || target.isMemberShape -> { throw IllegalArgumentException("lists should be handled at a higher level") From ae35de2e391fc8b7abcab13704503d5114d1ee68 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Mon, 10 Oct 2022 10:25:00 +0100 Subject: [PATCH 29/45] Undo unwanted change to model --- codegen-core/common-test-models/pokemon-common.smithy | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/codegen-core/common-test-models/pokemon-common.smithy b/codegen-core/common-test-models/pokemon-common.smithy index d3f7bc5115..3198cb8c74 100644 --- a/codegen-core/common-test-models/pokemon-common.smithy +++ b/codegen-core/common-test-models/pokemon-common.smithy @@ -53,11 +53,9 @@ structure GetServerStatisticsInput { } structure GetServerStatisticsOutput { /// The number of calls executed by the server. @required - calls_count: MyFloat, + calls_count: Long, } -float MyFloat - list FlavorTextEntries { member: FlavorText } From bed03b535edf8bd9d4ebf9413d7ea97d24e846bd Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Mon, 10 Oct 2022 10:33:28 +0100 Subject: [PATCH 30/45] Re-add reborrow in HttpBindingGenerator --- .../core/smithy/generators/http/HttpBindingGenerator.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index 827d30e0b9..e76ed60ac9 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -490,7 +490,7 @@ class HttpBindingGenerator( rustTemplate( """ let header_value = $safeName; - let header_value = http::header::HeaderValue::try_from(header_value).map_err(|err| { + let header_value = http::header::HeaderValue::try_from(&*header_value).map_err(|err| { #{build_error}::InvalidField { field: "$memberName", details: format!("`{}` cannot be used as a header value: {}", &${ memberShape.redactIfNecessary(model, "header_value") }, err)} @@ -557,7 +557,7 @@ class HttpBindingGenerator( target.isStringShape -> { if (target.hasTrait()) { val func = writer.format(RuntimeType.Base64Encode(runtimeConfig)) - "&$func(&$targetName)" + "$func(&$targetName)" } else { quoteValue("AsRef::::as_ref($targetName)") } @@ -566,7 +566,7 @@ class HttpBindingGenerator( val timestampFormat = index.determineTimestampFormat(member, HttpBinding.Location.HEADER, defaultTimestampFormat) val timestampFormatType = RuntimeType.TimestampFormat(runtimeConfig, timestampFormat) - quoteValue("&$targetName.fmt(${writer.format(timestampFormatType)})?") + quoteValue("$targetName.fmt(${writer.format(timestampFormatType)})?") } target.isListShape || target.isMemberShape -> { throw IllegalArgumentException("lists should be handled at a higher level") From 7b424add066b6ce910e95cd439052e62f78d15fc Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Mon, 10 Oct 2022 11:29:11 +0100 Subject: [PATCH 31/45] Fix clippy::format-push-string in changelogger --- tools/changelogger/src/render.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/changelogger/src/render.rs b/tools/changelogger/src/render.rs index 0a61b3609c..9bb8e765a4 100644 --- a/tools/changelogger/src/render.rs +++ b/tools/changelogger/src/render.rs @@ -377,7 +377,10 @@ fn render(entries: &[ChangelogEntry], release_header: &str) -> (String, String) out.push_str("- @"); out.push_str(&contributor_handle); if !contribution_references.is_empty() { - out.push_str(&format!(" ({})", contribution_references)); + write!(&mut out, " ({})", contribution_references) + // The `Write` implementation for `String` is infallible, + // see https://doc.rust-lang.org/src/alloc/string.rs.html#2815 + .unwrap() } out.push('\n'); } From 60d27d1e9d3a68d7600c3a55860c8f6627dfac11 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Tue, 11 Oct 2022 09:42:30 +0100 Subject: [PATCH 32/45] Fix more uses of str.push_str(&format!(...)) --- tools/crate-hasher/src/file_list.rs | 3 ++- tools/sdk-sync/src/sync.rs | 3 ++- tools/smithy-rs-tool-common/src/git.rs | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/crate-hasher/src/file_list.rs b/tools/crate-hasher/src/file_list.rs index a7b10f39eb..03f6090cb6 100644 --- a/tools/crate-hasher/src/file_list.rs +++ b/tools/crate-hasher/src/file_list.rs @@ -5,6 +5,7 @@ use anyhow::{Context, Result}; use std::collections::BTreeSet; +use std::fmt::Write; use std::fs::Metadata; use std::path::Path; @@ -84,7 +85,7 @@ impl FileMetadata { /// Returns a string to hash for this file fn hash_entry(&self) -> String { let mut entry = String::with_capacity(7 + self.path.len() + 1 + self.sha256.len() + 1); - entry.push_str(&format!("{:06o} ", self.mode)); + write!(&mut entry, "{:06o} ", self.mode).unwrap(); entry.push_str(&self.path); entry.push(' '); entry.push_str(&self.sha256); diff --git a/tools/sdk-sync/src/sync.rs b/tools/sdk-sync/src/sync.rs index aa2fd6fc65..1512bd0909 100644 --- a/tools/sdk-sync/src/sync.rs +++ b/tools/sdk-sync/src/sync.rs @@ -10,6 +10,7 @@ use anyhow::{bail, Context, Result}; use smithy_rs_tool_common::git::{Commit, CommitHash, Git, GitCLI}; use smithy_rs_tool_common::macros::here; use std::collections::BTreeSet; +use std::fmt::Write; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::mpsc::{Sender, TryRecvError}; @@ -405,7 +406,7 @@ impl Sync { .map(|c| format!("{} <{}>", c.author_name, c.author_email)) .collect(); for author in authors { - commit_message.push_str(&format!("Co-authored-by: {}\n", author)); + writeln!(&mut commit_message, "Co-authored-by: {}", author).unwrap(); } commit_message } diff --git a/tools/smithy-rs-tool-common/src/git.rs b/tools/smithy-rs-tool-common/src/git.rs index b22543f0ab..b1b34aa263 100644 --- a/tools/smithy-rs-tool-common/src/git.rs +++ b/tools/smithy-rs-tool-common/src/git.rs @@ -7,7 +7,7 @@ use crate::shell::{handle_failure, output_text}; use anyhow::{bail, Context, Result}; use std::borrow::Cow; use std::ffi::OsStr; -use std::fmt; +use std::fmt::{self, Write}; use std::path::{Path, PathBuf}; use std::process::Command; use tracing::debug; @@ -415,7 +415,7 @@ fn split_file_names(value: &str) -> Vec { fn log_command(command: Command) -> Command { let mut message = String::new(); if let Some(cwd) = command.get_current_dir() { - message.push_str(&format!("[in {:?}]: ", cwd)); + write!(&mut message, "[in {:?}]: ", cwd).unwrap(); } message.push_str(command.get_program().to_str().expect("valid str")); for arg in command.get_args() { From 77f0b322f6ac45aae48dbd91e5fa06b99a2b2ccc Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Tue, 11 Oct 2022 09:42:49 +0100 Subject: [PATCH 33/45] Remove unnecessary parenthesis --- rust-runtime/aws-smithy-async/src/future/fn_stream.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-async/src/future/fn_stream.rs b/rust-runtime/aws-smithy-async/src/future/fn_stream.rs index 72fcacbd4d..3fdb280d5f 100644 --- a/rust-runtime/aws-smithy-async/src/future/fn_stream.rs +++ b/rust-runtime/aws-smithy-async/src/future/fn_stream.rs @@ -200,7 +200,7 @@ mod test { Box::pin(async move { for i in 0..5 { if i != 2 { - if (tx.send(Ok(i)).await).is_err() { + if tx.send(Ok(i)).await.is_err() { return; } } else { From ba28132b549322087194e89239b35580a0913b77 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Tue, 11 Oct 2022 09:45:37 +0100 Subject: [PATCH 34/45] Run ktlint --- .../codegen/client/smithy/customizations/AllowLintsGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt index cb83d78d36..e4de0bf3fe 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/AllowLintsGenerator.kt @@ -41,7 +41,7 @@ val AllowedClippyLints = listOf( "type_complexity", // Determining if the expression is the last one (to remove return) can make codegen harder in some cases. - "needless_return" + "needless_return", ) val AllowedRustdocLints = listOf( From 70785a1927b4c6e8a86b49754c239fec7a9593fe Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Tue, 11 Oct 2022 09:46:22 +0100 Subject: [PATCH 35/45] Update aws/rust-runtime/aws-http/src/content_encoding.rs Co-authored-by: John DiSanti --- aws/rust-runtime/aws-http/src/content_encoding.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/rust-runtime/aws-http/src/content_encoding.rs b/aws/rust-runtime/aws-http/src/content_encoding.rs index bb66963ab9..1c1a56d44b 100644 --- a/aws/rust-runtime/aws-http/src/content_encoding.rs +++ b/aws/rust-runtime/aws-http/src/content_encoding.rs @@ -513,7 +513,7 @@ mod tests { }; let timeout_duration = Duration::from_secs(3); - if (tokio::time::timeout(timeout_duration, test_fut).await).is_err() { + if tokio::time::timeout(timeout_duration, test_fut).await.is_err() { panic!( "test_aws_chunked_encoding_sputtering_body timed out after {timeout_duration:?}" ); From 2cf21d1e51d5a60ad3a71cb9618646b8ae457f53 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Tue, 11 Oct 2022 09:46:29 +0100 Subject: [PATCH 36/45] Update aws/rust-runtime/aws-http/src/content_encoding.rs Co-authored-by: John DiSanti --- aws/rust-runtime/aws-http/src/content_encoding.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/rust-runtime/aws-http/src/content_encoding.rs b/aws/rust-runtime/aws-http/src/content_encoding.rs index 1c1a56d44b..f93a1f6ddf 100644 --- a/aws/rust-runtime/aws-http/src/content_encoding.rs +++ b/aws/rust-runtime/aws-http/src/content_encoding.rs @@ -462,7 +462,7 @@ mod tests { }; let timeout_duration = Duration::from_secs(3); - if (tokio::time::timeout(timeout_duration, test_fut).await).is_err() { + if tokio::time::timeout(timeout_duration, test_fut).await.is_err() { panic!("test_aws_chunked_encoding timed out after {timeout_duration:?}"); } } From e68dfb7be743f1b4320deb33028424c154d8ce44 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Tue, 11 Oct 2022 13:12:02 +0100 Subject: [PATCH 37/45] Ignore doctest for non-exported macro Rust 1.62 introduced a breaking change where doctests for non-exported macros are now run by default. These don't compile because the macro can't be imported in it. See https://github.com/rust-lang/rust/issues/97030 for more info. --- aws/rust-runtime/aws-types/src/build_metadata.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/rust-runtime/aws-types/src/build_metadata.rs b/aws/rust-runtime/aws-types/src/build_metadata.rs index 32e532c773..959f728411 100644 --- a/aws/rust-runtime/aws-types/src/build_metadata.rs +++ b/aws/rust-runtime/aws-types/src/build_metadata.rs @@ -41,7 +41,7 @@ pub enum OsFamily { /// is set to a specific value. This macro simplifies checking the current OS family. /// /// Usage: -/// ```rust +/// ```ignore /// let os = get_os_family!(target_os: ("linux", OsFamily::Windows), ("android", OsFamily::Android)); /// ``` macro_rules! get_os_family { From f1c8beb93e85c3ebeccc385ee609cf1b1cb028ae Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Tue, 11 Oct 2022 16:57:38 +0100 Subject: [PATCH 38/45] Run cargo fmt --- aws/rust-runtime/aws-http/src/content_encoding.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aws/rust-runtime/aws-http/src/content_encoding.rs b/aws/rust-runtime/aws-http/src/content_encoding.rs index f93a1f6ddf..6b900ab750 100644 --- a/aws/rust-runtime/aws-http/src/content_encoding.rs +++ b/aws/rust-runtime/aws-http/src/content_encoding.rs @@ -462,7 +462,10 @@ mod tests { }; let timeout_duration = Duration::from_secs(3); - if tokio::time::timeout(timeout_duration, test_fut).await.is_err() { + if tokio::time::timeout(timeout_duration, test_fut) + .await + .is_err() + { panic!("test_aws_chunked_encoding timed out after {timeout_duration:?}"); } } @@ -513,7 +516,10 @@ mod tests { }; let timeout_duration = Duration::from_secs(3); - if tokio::time::timeout(timeout_duration, test_fut).await.is_err() { + if tokio::time::timeout(timeout_duration, test_fut) + .await + .is_err() + { panic!( "test_aws_chunked_encoding_sputtering_body timed out after {timeout_duration:?}" ); From a63c7b8ba77e48ec51b2fe330b4fa685cdabe92b Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Tue, 11 Oct 2022 17:07:48 +0100 Subject: [PATCH 39/45] Use $crate instead of crate in macro --- tools/ci-cdk/canary-lambda/src/canary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci-cdk/canary-lambda/src/canary.rs b/tools/ci-cdk/canary-lambda/src/canary.rs index 242c9f0c07..d46345a32d 100644 --- a/tools/ci-cdk/canary-lambda/src/canary.rs +++ b/tools/ci-cdk/canary-lambda/src/canary.rs @@ -20,7 +20,7 @@ macro_rules! mk_canary { pub(crate) fn mk_canary( clients: &Clients, env: &CanaryEnv, - ) -> Option<(&'static str, crate::canary::CanaryFuture)> { + ) -> Option<(&'static str, $crate::canary::CanaryFuture)> { Some(($name, Box::pin($run_canary(clients, env)))) } }; From 405f7478f57ea9dee1d6bc6595c13a621ad10a0f Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Wed, 12 Oct 2022 10:19:28 +0100 Subject: [PATCH 40/45] Revert "Implement Eq on types in aws-smithy-types" This reverts commit c45a6b5a56d391923efce3c884291c330218982d. --- rust-runtime/aws-smithy-types/src/date_time/mod.rs | 2 +- rust-runtime/aws-smithy-types/src/lib.rs | 2 +- rust-runtime/aws-smithy-types/src/retry.rs | 4 ++-- rust-runtime/aws-smithy-types/src/timeout/config.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rust-runtime/aws-smithy-types/src/date_time/mod.rs b/rust-runtime/aws-smithy-types/src/date_time/mod.rs index 370cbad10c..bb1120c829 100644 --- a/rust-runtime/aws-smithy-types/src/date_time/mod.rs +++ b/rust-runtime/aws-smithy-types/src/date_time/mod.rs @@ -46,7 +46,7 @@ const NANOS_PER_SECOND_U32: u32 = 1_000_000_000; /// The [`aws-smithy-types-convert`](https://crates.io/crates/aws-smithy-types-convert) crate /// can be used for conversions to/from other libraries, such as /// [`time`](https://crates.io/crates/time) or [`chrono`](https://crates.io/crates/chrono). -#[derive(Debug, PartialEq, Eq, Clone, Copy)] +#[derive(Debug, PartialEq, Clone, Copy)] pub struct DateTime { seconds: i64, subsecond_nanos: u32, diff --git a/rust-runtime/aws-smithy-types/src/lib.rs b/rust-runtime/aws-smithy-types/src/lib.rs index f88b7b2b03..6a18c187a0 100644 --- a/rust-runtime/aws-smithy-types/src/lib.rs +++ b/rust-runtime/aws-smithy-types/src/lib.rs @@ -27,7 +27,7 @@ pub use crate::date_time::DateTime; /// Binary Blob Type /// /// Blobs represent protocol-agnostic binary content. -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Debug, PartialEq, Clone)] pub struct Blob { inner: Vec, } diff --git a/rust-runtime/aws-smithy-types/src/retry.rs b/rust-runtime/aws-smithy-types/src/retry.rs index 7bfe0bdfd4..56556154bb 100644 --- a/rust-runtime/aws-smithy-types/src/retry.rs +++ b/rust-runtime/aws-smithy-types/src/retry.rs @@ -130,7 +130,7 @@ impl FromStr for RetryMode { /// Builder for [`RetryConfig`]. #[non_exhaustive] -#[derive(Debug, Default, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Clone, PartialEq)] pub struct RetryConfigBuilder { mode: Option, max_attempts: Option, @@ -217,7 +217,7 @@ impl RetryConfigBuilder { /// Retry configuration for requests. #[non_exhaustive] -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq)] pub struct RetryConfig { mode: RetryMode, max_attempts: u32, diff --git a/rust-runtime/aws-smithy-types/src/timeout/config.rs b/rust-runtime/aws-smithy-types/src/timeout/config.rs index a815dacd40..68d1296695 100644 --- a/rust-runtime/aws-smithy-types/src/timeout/config.rs +++ b/rust-runtime/aws-smithy-types/src/timeout/config.rs @@ -197,7 +197,7 @@ impl From for TimeoutConfigBuilder { /// # } /// ``` #[non_exhaustive] -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Debug)] pub struct TimeoutConfig { connect_timeout: Option, read_timeout: Option, @@ -274,7 +274,7 @@ impl TimeoutConfig { /// Configuration subset of [`TimeoutConfig`] for operation timeouts #[non_exhaustive] -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Debug)] pub struct OperationTimeoutConfig { operation_timeout: Option, operation_attempt_timeout: Option, From 9c47ac8794d2b1d0b6eecb90be35a6b05bfa2b55 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Wed, 12 Oct 2022 10:20:31 +0100 Subject: [PATCH 41/45] Revert "Implement Eq on types in aws-smithy-eventstream" This reverts commit 78f4b07344d2cbb9d06b30ffd9bad16031fdd83b. --- rust-runtime/aws-smithy-eventstream/src/frame.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-eventstream/src/frame.rs b/rust-runtime/aws-smithy-eventstream/src/frame.rs index ad9d3d9e14..79bd8fe15a 100644 --- a/rust-runtime/aws-smithy-eventstream/src/frame.rs +++ b/rust-runtime/aws-smithy-eventstream/src/frame.rs @@ -96,7 +96,7 @@ mod value { /// Event Stream frame header value. #[non_exhaustive] - #[derive(Clone, Debug, PartialEq, Eq)] + #[derive(Clone, Debug, PartialEq)] pub enum HeaderValue { Bool(bool), Byte(i8), From 47fa6620254e44c5f9d675605429773e7988005f Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Wed, 12 Oct 2022 10:20:58 +0100 Subject: [PATCH 42/45] Revert "Implement Eq on types in aws-smithy-xml" This reverts commit 590f01af7326bde7de97cae97feeedf593b9239b. --- rust-runtime/aws-smithy-eventstream/src/frame.rs | 4 ++-- rust-runtime/aws-smithy-xml/src/decode.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rust-runtime/aws-smithy-eventstream/src/frame.rs b/rust-runtime/aws-smithy-eventstream/src/frame.rs index 79bd8fe15a..dbe0a638a3 100644 --- a/rust-runtime/aws-smithy-eventstream/src/frame.rs +++ b/rust-runtime/aws-smithy-eventstream/src/frame.rs @@ -300,7 +300,7 @@ pub use value::HeaderValue; /// Event Stream header. #[non_exhaustive] -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "derive-arbitrary", derive(arbitrary::Arbitrary))] pub struct Header { name: StrBytes, @@ -368,7 +368,7 @@ pub fn write_headers_to(headers: &[Header], mut buffer: B) -> Result< /// Event Stream message. #[non_exhaustive] -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq)] pub struct Message { headers: Vec
, payload: Bytes, diff --git a/rust-runtime/aws-smithy-xml/src/decode.rs b/rust-runtime/aws-smithy-xml/src/decode.rs index f4ee499e3d..936d4c3d32 100644 --- a/rust-runtime/aws-smithy-xml/src/decode.rs +++ b/rust-runtime/aws-smithy-xml/src/decode.rs @@ -51,7 +51,7 @@ impl XmlError { } } -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Debug)] pub struct Name<'a> { pub prefix: &'a str, pub local: &'a str, @@ -72,14 +72,14 @@ impl Name<'_> { } } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq)] pub struct Attr<'a> { name: Name<'a>, // attribute values can be escaped (e.g. with double quotes, so we need a Cow) value: Cow<'a, str>, } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq)] pub struct StartEl<'a> { name: Name<'a>, attributes: Vec>, From 90f5429762b9be2826568ccba8efbdab1307402e Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Wed, 12 Oct 2022 10:21:33 +0100 Subject: [PATCH 43/45] Revert "Implement Eq on aws-sigv4" This reverts commit d78bb62124c4b3a24a35bdd655995de11252d17f. --- aws/rust-runtime/aws-sigv4/src/http_request/settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/rust-runtime/aws-sigv4/src/http_request/settings.rs b/aws/rust-runtime/aws-sigv4/src/http_request/settings.rs index 890ba5b362..e78ef7d4a9 100644 --- a/aws/rust-runtime/aws-sigv4/src/http_request/settings.rs +++ b/aws/rust-runtime/aws-sigv4/src/http_request/settings.rs @@ -10,7 +10,7 @@ use std::time::Duration; pub type SigningParams<'a> = crate::SigningParams<'a, SigningSettings>; /// HTTP-specific signing settings -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq)] #[non_exhaustive] pub struct SigningSettings { /// Specifies how to encode the request URL when signing. Some services do not decode From a1333435bb2c0535004826c1aeafb41b456e5f77 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Wed, 12 Oct 2022 10:21:59 +0100 Subject: [PATCH 44/45] Revert "Implement Eq on types in aws-smithy-http-server-python" This reverts commit f2cd9018844130d441820742dc1cf1c7abeaa38b. --- rust-runtime/aws-smithy-http-server-python/src/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-runtime/aws-smithy-http-server-python/src/types.rs b/rust-runtime/aws-smithy-http-server-python/src/types.rs index 48dc0a6926..98adbd4119 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/types.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/types.rs @@ -26,7 +26,7 @@ use crate::PyError; /// Python Wrapper for [aws_smithy_types::Blob]. #[pyclass] -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq)] pub struct Blob(aws_smithy_types::Blob); impl Blob { @@ -88,7 +88,7 @@ impl<'blob> From<&'blob Blob> for &'blob aws_smithy_types::Blob { /// Python Wrapper for [aws_smithy_types::date_time::DateTime]. #[pyclass] -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq)] pub struct DateTime(aws_smithy_types::date_time::DateTime); #[pyclass] From 7b5b6a9cafb612bdd4decd73ce51613178ef30c2 Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Wed, 12 Oct 2022 10:22:34 +0100 Subject: [PATCH 45/45] Revert "Implement Eq on aws-smithy-checksums::Error" This reverts commit 5da170405e12d5077f67b8f8e41c2319138244d4. --- rust-runtime/aws-smithy-checksums/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-checksums/src/lib.rs b/rust-runtime/aws-smithy-checksums/src/lib.rs index 3c652258cd..98ed65d34c 100644 --- a/rust-runtime/aws-smithy-checksums/src/lib.rs +++ b/rust-runtime/aws-smithy-checksums/src/lib.rs @@ -82,7 +82,7 @@ impl ChecksumAlgorithm { } } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq)] pub enum Error { UnknownChecksumAlgorithm(String), }