Skip to content

Commit

Permalink
Upgrade to Rust 1.62.0 (#1825)
Browse files Browse the repository at this point in the history
* Run clippy --fix for Rust 1.62.0 and format the resulting code

* Run clippy --fix on all targets

* Run clippy --fix with all features enabled

* Avoid extra allocation

* Use more idiomatic assert

* Ignore noisy lint

* Update pyo3 and pyo3-asyncio to 0.17.0

* Implement Eq on aws-smithy-checksums::Error

* Implement Eq on Protocol

* Replace conditionals with range-containment

* Implement Eq on types in aws-smithy-types

* Implement Eq on types in aws-smithy-http-server-python

* Implement Eq on types in aws-smithy-eventstream

* Implement Eq on types in aws-smithy-xml

* Implement Eq on aws-sigv4

* Update CI to use Rust 1.62.0

* Add Eq for generated types that implement PartialEq

* Allow clippy::needless_return in generated code

* Remove unnecessary reborrow in http_serde

* Remove unnecessary borrow in operation_deser

* Add CHANGELOG entries

* Revert "Add Eq for generated types that implement PartialEq"

This reverts commit 5169bd9.

* Update pyo3 and pyo3-asyncio in generated code for python server

* Allow clippy::derive_partial_eq_without_eq on structs and builders

* Run clippy on tools

* Fix accidental move in generated code

* Revert "Allow clippy::derive_partial_eq_without_eq on structs and builders"

This reverts commit 068c63c.

* Fix another accidental move in generated code

* Undo unwanted change to model

* Re-add reborrow in HttpBindingGenerator

* Fix clippy::format-push-string in changelogger

* Fix more uses of str.push_str(&format!(...))

* Remove unnecessary parenthesis

* Run ktlint

* Update aws/rust-runtime/aws-http/src/content_encoding.rs

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Update aws/rust-runtime/aws-http/src/content_encoding.rs

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* 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 rust-lang/rust#97030 for more info.

* Run cargo fmt

* Use $crate instead of crate in macro

* Revert "Implement Eq on types in aws-smithy-types"

This reverts commit c45a6b5.

* Revert "Implement Eq on types in aws-smithy-eventstream"

This reverts commit 78f4b07.

* Revert "Implement Eq on types in aws-smithy-xml"

This reverts commit 590f01a.

* Revert "Implement Eq on aws-sigv4"

This reverts commit d78bb62.

* Revert "Implement Eq on types in aws-smithy-http-server-python"

This reverts commit f2cd901.

* Revert "Implement Eq on aws-smithy-checksums::Error"

This reverts commit 5da1704.

Co-authored-by: Julian Antonielli <julianantonielli@gmail.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
  • Loading branch information
3 people authored Oct 17, 2022
1 parent c7ddb16 commit 18d969e
Show file tree
Hide file tree
Showing 49 changed files with 122 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
workflow_call:

env:
rust_version: 1.61.0
rust_version: 1.62.0
rust_toolchain_components: clippy,rustfmt

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: true

env:
rust_version: 1.61.0
rust_version: 1.62.0

name: Release smithy-rs
run-name: ${{ github.workflow }} - ${{ inputs.dry_run && 'Dry run' || 'Production run' }}
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions aws/rust-runtime/aws-endpoint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 9 additions & 3 deletions aws/rust-runtime/aws-http/src/content_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down Expand Up @@ -462,7 +462,10 @@ 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:?}");
}
}
Expand Down Expand Up @@ -513,7 +516,10 @@ 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:?}"
);
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-http/src/recursion_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ mod test {
)
}
assert_ok(validate_headers(
&augmented_req.http().headers(),
augmented_req.http().headers(),
test_case.request_headers_after(),
))
}
Expand Down
6 changes: 2 additions & 4 deletions aws/rust-runtime/aws-http/src/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ mod test {
) -> Result<SdkSuccess<()>, SdkError<E>> {
Err(SdkError::ServiceError {
err,
raw: operation::Response::new(raw.map(|b| SdkBody::from(b))),
raw: operation::Response::new(raw.map(SdkBody::from)),
})
}

Expand Down Expand Up @@ -265,9 +265,7 @@ mod test {
policy.classify_retry(
Result::<SdkSuccess<()>, SdkError<UnmodeledError>>::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()
),
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn test_operation() -> Operation<TestOperationParser, AwsResponseRetryClassifier
.body(SdkBody::from("request body"))
.unwrap(),
)
.augment(|req, mut conf| {
.augment(|req, conf| {
conf.insert(
EndpointShim::from_resolver(aws_endpoint::partition::endpoint::Metadata {
uri_template: "test-service.{region}.amazonaws.com",
Expand All @@ -93,7 +93,7 @@ fn test_operation() -> Operation<TestOperationParser, AwsResponseRetryClassifier
.resolve_endpoint(&Params::new(Some(Region::new("test-region")))),
);
aws_http::auth::set_provider(
&mut conf,
conf,
SharedCredentialsProvider::new(Credentials::new(
"access_key",
"secret_key",
Expand Down
4 changes: 2 additions & 2 deletions aws/rust-runtime/aws-sigv4/src/event_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: (),
};

Expand Down Expand Up @@ -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: (),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ mod tests {
region: "us-east-1",
service: "iam",
};
assert_eq!(format!("{}\n", scope.to_string()), expected);
assert_eq!(format!("{}\n", scope), expected);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-types/src/build_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion rust-runtime/aws-smithy-async/src/future/fn_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ mod test {
Box::pin(async move {
for i in 0..5 {
if i != 2 {
if let Err(_) = tx.send(Ok(i)).await {
if tx.send(Ok(i)).await.is_err() {
return;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-eventstream/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ mod message_tests {
0x36,
];

let result = Message::read_from(&mut Bytes::from_static(&data)).unwrap();
let result = Message::read_from(&mut Bytes::from_static(data)).unwrap();
assert_eq!(result.headers(), Vec::new());

let expected_payload = b"{'foo':'bar'}";
Expand All @@ -620,7 +620,7 @@ mod message_tests {
0x7d, 0x8D, 0x9C, 0x08, 0xB1,
];

let result = Message::read_from(&mut Bytes::from_static(&data)).unwrap();
let result = Message::read_from(&mut Bytes::from_static(data)).unwrap();
assert_eq!(
result.headers(),
vec![Header::new(
Expand Down
2 changes: 1 addition & 1 deletion rust-runtime/aws-smithy-eventstream/src/str_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod tests {
let str_bytes: StrBytes = valid_utf8.into();
assert_eq!(valid_utf8.as_bytes(), str_bytes.as_bytes());
assert_eq!(valid_utf8, str_bytes.as_str());
assert_eq!(valid_utf8, str_bytes.clone().as_str());
assert_eq!(valid_utf8, str_bytes.as_str());
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-http-server-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ lambda_http = "0.6.0"
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ mod tests {
let sensitive = Sensitive(inner);
let actual = format!("{}", sensitive);
let expected = if cfg!(feature = "unredacted-logging") {
format!("{}", inner)
inner.to_string()
} else {
format!("{}", REDACTED)
REDACTED.to_string()
};
assert_eq!(actual, expected)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ mod tests {
let originals = EXAMPLES.into_iter().map(Uri::from_static);
for original in originals {
let expected = original.path().to_string();
let output = Label::new(&original.path(), |_| false, None).to_string();
let output = Label::new(original.path(), |_| false, None).to_string();
assert_eq!(output, expected, "original = {original}");
}
}
Expand Down Expand Up @@ -222,7 +222,7 @@ mod tests {
let originals = EXAMPLES.into_iter().map(Uri::from_static);
let expecteds = ALL_EXAMPLES.into_iter().map(Uri::from_static);
for (original, expected) in originals.zip(expecteds) {
let output = Label::new(&original.path(), |_| true, None).to_string();
let output = Label::new(original.path(), |_| true, None).to_string();
assert_eq!(output, expected.path(), "original = {original}");
}
}
Expand Down Expand Up @@ -258,7 +258,7 @@ mod tests {
let originals = EXAMPLES.into_iter().map(Uri::from_static);
let expecteds = GREEDY_EXAMPLES.into_iter().map(Uri::from_static);
for (original, expected) in originals.zip(expecteds) {
let output = Label::new(&original.path(), |_| false, Some(GreedyLabel::new(1, 0))).to_string();
let output = Label::new(original.path(), |_| false, Some(GreedyLabel::new(1, 0))).to_string();
assert_eq!(output, expected.path(), "original = {original}");
}
}
Expand Down Expand Up @@ -294,7 +294,7 @@ mod tests {
let originals = EXAMPLES.into_iter().map(Uri::from_static);
let expecteds = GREEDY_EXAMPLES_OFFSET.into_iter().map(Uri::from_static);
for (original, expected) in originals.zip(expecteds) {
let output = Label::new(&original.path(), |_| false, Some(GreedyLabel::new(1, 1))).to_string();
let output = Label::new(original.path(), |_| false, Some(GreedyLabel::new(1, 1))).to_string();
assert_eq!(output, expected.path(), "original = {original}");
}
}
Expand All @@ -321,7 +321,7 @@ mod tests {
let originals = EXTRA_EXAMPLES_UNREDACTED.into_iter().map(Uri::from_static);
let expecteds = EXTRA_EXAMPLES_REDACTED.into_iter().map(Uri::from_static);
for (original, expected) in originals.zip(expecteds) {
let output = Label::new(&original.path(), |_| false, Some(GreedyLabel::new(2, 5))).to_string();
let output = Label::new(original.path(), |_| false, Some(GreedyLabel::new(2, 5))).to_string();
assert_eq!(output, expected.path(), "original = {original}");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mod tests {
let originals = EXAMPLES.into_iter().chain(QUERY_STRING_EXAMPLES).map(Uri::from_static);
for original in originals {
if let Some(query) = original.query() {
let output = Query::new(&query, |_| QueryMarker::default()).to_string();
let output = Query::new(query, |_| QueryMarker::default()).to_string();
assert_eq!(output, query, "original = {original}");
}
}
Expand All @@ -142,7 +142,7 @@ mod tests {
let originals = QUERY_STRING_EXAMPLES.into_iter().map(Uri::from_static);
let expecteds = ALL_KEYS_QUERY_STRING_EXAMPLES.into_iter().map(Uri::from_static);
for (original, expected) in originals.zip(expecteds) {
let output = Query::new(&original.query().unwrap(), |_| QueryMarker {
let output = Query::new(original.query().unwrap(), |_| QueryMarker {
key: true,
value: false,
})
Expand All @@ -156,7 +156,7 @@ mod tests {
let originals = QUERY_STRING_EXAMPLES.into_iter().map(Uri::from_static);
let expecteds = ALL_VALUES_QUERY_STRING_EXAMPLES.into_iter().map(Uri::from_static);
for (original, expected) in originals.zip(expecteds) {
let output = Query::new(&original.query().unwrap(), |_| QueryMarker {
let output = Query::new(original.query().unwrap(), |_| QueryMarker {
key: false,
value: true,
})
Expand All @@ -170,7 +170,7 @@ mod tests {
let originals = QUERY_STRING_EXAMPLES.into_iter().map(Uri::from_static);
let expecteds = ALL_PAIRS_QUERY_STRING_EXAMPLES.into_iter().map(Uri::from_static);
for (original, expected) in originals.zip(expecteds) {
let output = Query::new(&original.query().unwrap(), |_| QueryMarker { key: true, value: true }).to_string();
let output = Query::new(original.query().unwrap(), |_| QueryMarker { key: true, value: true }).to_string();
assert_eq!(output, expected.query().unwrap(), "original = {original}");
}
}
Expand All @@ -180,7 +180,7 @@ mod tests {
let originals = QUERY_STRING_EXAMPLES.into_iter().map(Uri::from_static);
let expecteds = X_QUERY_STRING_EXAMPLES.into_iter().map(Uri::from_static);
for (original, expected) in originals.zip(expecteds) {
let output = Query::new(&original.query().unwrap(), |key| QueryMarker {
let output = Query::new(original.query().unwrap(), |key| QueryMarker {
key: false,
value: key == "x",
})
Expand Down
2 changes: 1 addition & 1 deletion rust-runtime/aws-smithy-http-server/src/protocols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ mod tests {
);
assert_eq!(found_mime, invalid_mime.parse::<mime::Mime>().ok());
}
_ => panic!("Unexpected `MissingContentTypeReason`: {}", e.to_string()),
_ => panic!("Unexpected `MissingContentTypeReason`: {}", e),
},
}
}
Expand Down
Loading

0 comments on commit 18d969e

Please sign in to comment.