diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 774c4f3c7a39b3220156f7bd24d22e264349771e..52b54efd45e6254021acfb630577b12aa8cdab0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ on: required: false env: - rust_version: 1.62.1 + rust_version: 1.63.0 rust_toolchain_components: clippy,rustfmt ENCRYPTED_DOCKER_PASSWORD: ${{ secrets.ENCRYPTED_DOCKER_PASSWORD }} DOCKER_LOGIN_TOKEN_PASSPHRASE: ${{ secrets.DOCKER_LOGIN_TOKEN_PASSPHRASE }} diff --git a/.github/workflows/claim-crate-names.yml b/.github/workflows/claim-crate-names.yml index 650b8cac7cddfa0b6f77a4132f29ee3604cbf6c4..63b5eac307992a57391a86cf5dd188fe5830eec6 100644 --- a/.github/workflows/claim-crate-names.yml +++ b/.github/workflows/claim-crate-names.yml @@ -10,7 +10,7 @@ concurrency: cancel-in-progress: true env: - rust_version: 1.62.1 + rust_version: 1.63.0 name: Claim unpublished crate names on crates.io run-name: ${{ github.workflow }} diff --git a/.github/workflows/pull-request-bot.yml b/.github/workflows/pull-request-bot.yml index 7bcd2e833f88ac8a00b83c07ffa489895713c714..131939fcb0d6410eba24f279df36aae539047595 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.62.1 + rust_version: 1.63.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 8cd5e74287774a685305a9b2d7424d3d6efbcf63..049fd53971be9767fd2452c8f4ad98c387dd0a71 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ concurrency: cancel-in-progress: true env: - rust_version: 1.62.1 + rust_version: 1.63.0 name: Release smithy-rs run-name: ${{ github.workflow }} ${{ inputs.semantic_version }} (${{ inputs.commit_sha }}) - ${{ inputs.dry_run && 'Dry run' || 'Production run' }} @@ -18,8 +18,8 @@ on: workflow_dispatch: inputs: commit_sha: - description: | - The SHA of the git commit that you want to release. + description: | + The SHA of the git commit that you want to release. You must use the non-abbreviated SHA (e.g. b2318b0 won't work!). required: true type: string @@ -75,8 +75,8 @@ jobs: # We need `always` here otherwise this job won't run if the previous job has been skipped # See https://samanpavel.medium.com/github-actions-conditional-job-execution-e6aa363d2867 if: | - always() && - needs.acquire-base-image.result == 'success' && + always() && + needs.acquire-base-image.result == 'success' && (needs.release-ci.result == 'success' || needs.release-ci.result == 'skipped') runs-on: ubuntu-latest outputs: @@ -234,7 +234,7 @@ jobs: shell: bash run: | set -eux - + # This will fail if other commits have been pushed to `main` after `commit_sha` # In particular, this will ALWAYS fail if you are creating a new release series from # a commit that is not the current tip of `main`. diff --git a/.github/workflows/update-sdk-next.yml b/.github/workflows/update-sdk-next.yml index 8fca2bbc62cf185403a63dcb0670f591f721779f..fd6082351e3cb9362c9f92efdc84c36d3f14dfc1 100644 --- a/.github/workflows/update-sdk-next.yml +++ b/.github/workflows/update-sdk-next.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Rust uses: dtolnay/rust-toolchain@master with: - toolchain: 1.62.1 + toolchain: 1.63.0 - name: Delete old SDK run: | - name: Generate a fresh SDK diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index fc4c4c2578b5c5f185517bd30b00e87999da307c..99476bb5b3bc7e4188d05f9346a04d72e8864a7a 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -9,4 +9,16 @@ # message = "Fix typos in module documentation for generated crates" # references = ["smithy-rs#920"] # meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"} -# author = "rcoh" \ No newline at end of file +# author = "rcoh" + +[[aws-sdk-rust]] +message = "Upgrade Rust MSRV to 1.63.0" +references = ["smithy-rs#2222"] +meta = { "breaking" = true, "tada" = true, "bug" = false } +author = "Nugine" + +[[smithy-rs]] +message = "Upgrade Rust MSRV to 1.63.0" +references = ["smithy-rs#2222"] +meta = { "breaking" = true, "tada" = true, "bug" = false, "target" = "all" } +author = "Nugine" diff --git a/aws/rust-runtime/aws-config/src/imds/client.rs b/aws/rust-runtime/aws-config/src/imds/client.rs index ba5cea046cb2ddd455d1cfbea9f3c72732752413..e791ec929a7daeafdcee35bb325dacb7fe81305f 100644 --- a/aws/rust-runtime/aws-config/src/imds/client.rs +++ b/aws/rust-runtime/aws-config/src/imds/client.rs @@ -917,7 +917,7 @@ pub(crate) mod test { imds_request("http://169.254.169.254/latest/metadata", TOKEN_A), http::Response::builder() .status(200) - .body(SdkBody::from(vec![0xA0 as u8, 0xA1 as u8])) + .body(SdkBody::from(vec![0xA0, 0xA1])) .unwrap(), ), ]); diff --git a/aws/rust-runtime/aws-config/src/lib.rs b/aws/rust-runtime/aws-config/src/lib.rs index 8ca695a7700707b69e91fd85d1c85ac1d268fd2d..fc82e6d1fe720e77c3954f9bccd2dad78a204037 100644 --- a/aws/rust-runtime/aws-config/src/lib.rs +++ b/aws/rust-runtime/aws-config/src/lib.rs @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_debug_implementations, missing_docs, diff --git a/aws/rust-runtime/aws-credential-types/src/lib.rs b/aws/rust-runtime/aws-credential-types/src/lib.rs index 1f790c3fca5bb44b0a9653f3ab7a8772a7a5533c..b2f8330b5892f96b8fc596f68997e1a1b3eb78ef 100644 --- a/aws/rust-runtime/aws-credential-types/src/lib.rs +++ b/aws/rust-runtime/aws-credential-types/src/lib.rs @@ -8,6 +8,7 @@ //! * An opaque struct representing credentials //! * Concrete implementations of credentials caching +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_debug_implementations, missing_docs, diff --git a/aws/rust-runtime/aws-endpoint/src/lib.rs b/aws/rust-runtime/aws-endpoint/src/lib.rs index c895143184596b120f34108785aa04030aeb8999..deb4b6b670b726d16adfdc4b45f33e6e750f02bd 100644 --- a/aws/rust-runtime/aws-endpoint/src/lib.rs +++ b/aws/rust-runtime/aws-endpoint/src/lib.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] + use std::collections::HashMap; use std::error::Error; use std::fmt; @@ -270,7 +272,7 @@ mod test { let mut req = operation::Request::new(req); { let mut props = req.properties_mut(); - props.insert(region.clone()); + props.insert(region); props.insert(SigningService::from_static("qldb")); props.insert(endpoint); }; diff --git a/aws/rust-runtime/aws-http/src/auth.rs b/aws/rust-runtime/aws-http/src/auth.rs index c91b4c5bb51b7980189ce3abff918a247073138d..98e0e219bb0fdccff844f4260809f48d3b77062d 100644 --- a/aws/rust-runtime/aws-http/src/auth.rs +++ b/aws/rust-runtime/aws-http/src/auth.rs @@ -188,10 +188,7 @@ mod tests { .create_cache(SharedCredentialsProvider::new(provide_credentials_fn( || async { Ok(Credentials::for_tests()) }, ))); - set_credentials_cache( - &mut req.properties_mut(), - SharedCredentialsCache::from(credentials_cache), - ); + set_credentials_cache(&mut req.properties_mut(), credentials_cache); let req = CredentialsStage::new() .apply(req) .await diff --git a/aws/rust-runtime/aws-http/src/lib.rs b/aws/rust-runtime/aws-http/src/lib.rs index b000c3d6aeaaf5ca07497925f389593260672899..1ec861b954cd6c81fdc8507b54d162cb63749a93 100644 --- a/aws/rust-runtime/aws-http/src/lib.rs +++ b/aws/rust-runtime/aws-http/src/lib.rs @@ -5,6 +5,7 @@ //! Provides user agent and credentials middleware for the AWS SDK. +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_docs, rustdoc::missing_crate_level_docs, 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 59dea2ca41d34c2c8b7355bd1ee00fc040b52fc0..d99e1b11231f723501299fc478987474fe390656 100644 --- a/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs +++ b/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs @@ -269,7 +269,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(); + file.as_file_mut().write_all(line.as_bytes()).unwrap(); crc32c_checksum.update(line.as_bytes()); } diff --git a/aws/rust-runtime/aws-inlineable/src/lib.rs b/aws/rust-runtime/aws-inlineable/src/lib.rs index b4e00994d41735053e2de04b25a5776d18842faa..97acb899830695f82c5b91227fd0d9b09fd93e1f 100644 --- a/aws/rust-runtime/aws-inlineable/src/lib.rs +++ b/aws/rust-runtime/aws-inlineable/src/lib.rs @@ -10,6 +10,7 @@ //! This is _NOT_ intended to be an actual crate. It is a cargo project to solely to aid //! with local development of the SDK. +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_docs, rustdoc::missing_crate_level_docs, diff --git a/aws/rust-runtime/aws-sig-auth/src/lib.rs b/aws/rust-runtime/aws-sig-auth/src/lib.rs index 61ae88e81c4e1004f216b5e9449abec2b9124571..643b3ff216b795d2637c2fc3c0843c1e99d53f7c 100644 --- a/aws/rust-runtime/aws-sig-auth/src/lib.rs +++ b/aws/rust-runtime/aws-sig-auth/src/lib.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] + //! AWS Signature Authentication Package //! //! This crate may be used to generate presigned URLs for unmodeled behavior such as `rds-iam-token` diff --git a/aws/rust-runtime/aws-sigv4/src/http_request/query_writer.rs b/aws/rust-runtime/aws-sigv4/src/http_request/query_writer.rs index 40a98d9aba3d686edcaa941088a6614231696cd4..8ee4cdc55ed2dd4cebaf9c991a4c8930ae3e47cd 100644 --- a/aws/rust-runtime/aws-sigv4/src/http_request/query_writer.rs +++ b/aws/rust-runtime/aws-sigv4/src/http_request/query_writer.rs @@ -142,7 +142,7 @@ mod test { let mut query_writer = QueryWriter::new(&uri); query_writer.insert("key", value); - if let Err(_) = std::panic::catch_unwind(|| query_writer.build_uri()) { + if std::panic::catch_unwind(|| query_writer.build_uri()).is_err() { problematic_chars.push(char::from(byte)); }; } diff --git a/aws/rust-runtime/aws-sigv4/src/http_request/sign.rs b/aws/rust-runtime/aws-sigv4/src/http_request/sign.rs index 69f5c00819ac03debb32dcd8370a1de498ef10d5..d120a401e7d4f466be18f2fef68416f6d0fa60db 100644 --- a/aws/rust-runtime/aws-sigv4/src/http_request/sign.rs +++ b/aws/rust-runtime/aws-sigv4/src/http_request/sign.rs @@ -380,9 +380,11 @@ mod tests { #[test] fn test_sign_vanilla_with_query_params() { - let mut settings = SigningSettings::default(); - settings.signature_location = SignatureLocation::QueryParams; - settings.expires_in = Some(Duration::from_secs(35)); + let settings = SigningSettings { + signature_location: SignatureLocation::QueryParams, + expires_in: Some(Duration::from_secs(35)), + ..Default::default() + }; let params = SigningParams { access_key: "AKIDEXAMPLE", secret_key: "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY", diff --git a/aws/rust-runtime/aws-sigv4/src/lib.rs b/aws/rust-runtime/aws-sigv4/src/lib.rs index be2552f5781e30a37572d3c1e9fa1ff74ef74876..14d7a7b5fd2410169804a7a441a01fba7f492899 100644 --- a/aws/rust-runtime/aws-sigv4/src/lib.rs +++ b/aws/rust-runtime/aws-sigv4/src/lib.rs @@ -6,6 +6,7 @@ //! Provides functions for calculating Sigv4 signing keys, signatures, and //! optional utilities for signing HTTP requests and Event Stream messages. +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_docs, rustdoc::missing_crate_level_docs, diff --git a/aws/rust-runtime/aws-types/src/lib.rs b/aws/rust-runtime/aws-types/src/lib.rs index 795ff08849b3889ed39e33a9b504f62e99aa3de1..600adc83cc2c9c753716e738899cdfc6921e988c 100644 --- a/aws/rust-runtime/aws-types/src/lib.rs +++ b/aws/rust-runtime/aws-types/src/lib.rs @@ -5,6 +5,7 @@ //! Cross-service types for the AWS SDK. +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_docs, rustdoc::missing_crate_level_docs, diff --git a/aws/sdk/integration-tests/s3/tests/endpoints.rs b/aws/sdk/integration-tests/s3/tests/endpoints.rs index 93c37f5c87259e405a766680065c1a0dc58f26fc..02b1718569ef58ca335ca62832fa9f6a1807ec26 100644 --- a/aws/sdk/integration-tests/s3/tests/endpoints.rs +++ b/aws/sdk/integration-tests/s3/tests/endpoints.rs @@ -16,7 +16,7 @@ fn test_client(update_builder: fn(Builder) -> Builder) -> (CaptureRequestReceive let sdk_config = SdkConfig::builder() .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-west-4")) - .http_connector(conn.clone()) + .http_connector(conn) .build(); let client = Client::from_conf(update_builder(Builder::from(&sdk_config)).build()); (captured_request, client) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/ExpressionGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/ExpressionGenerator.kt index f0bad1aac2e92e4e25874c4b000a35f6cd7e7266..b0d45366ed0982e3fda0fa9669cf13724ba76591 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/ExpressionGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/ExpressionGenerator.kt @@ -65,7 +65,14 @@ class ExpressionGenerator( getAttr.path.toList().forEach { part -> when (part) { is GetAttr.Part.Key -> rust(".${part.key().rustName()}()") - is GetAttr.Part.Index -> rust(".get(${part.index()}).cloned()") // we end up with Option<&&T>, we need to get to Option<&T> + is GetAttr.Part.Index -> { + if (part.index() == 0) { + // In this case, `.first()` is more idiomatic and `.get(0)` triggers lint warnings + rust(".first().cloned()") + } else { + rust(".get(${part.index()}).cloned()") // we end up with Option<&&T>, we need to get to Option<&T> + } + } } } if (ownership == Ownership.Owned && getAttr.type() != Type.bool()) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt index b5a24be36c03259856c1e284eebe09d693bf3611..3cc82af7a0d3ccf1aad909f99eab23fc5dc196ab 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -211,9 +211,9 @@ class ProtocolTestGenerator( checkQueryParams(this, httpRequestTestCase.queryParams) checkForbidQueryParams(this, httpRequestTestCase.forbidQueryParams) checkRequiredQueryParams(this, httpRequestTestCase.requireQueryParams) - checkHeaders(this, "&http_request.headers()", httpRequestTestCase.headers) - checkForbidHeaders(this, "&http_request.headers()", httpRequestTestCase.forbidHeaders) - checkRequiredHeaders(this, "&http_request.headers()", httpRequestTestCase.requireHeaders) + checkHeaders(this, "http_request.headers()", httpRequestTestCase.headers) + checkForbidHeaders(this, "http_request.headers()", httpRequestTestCase.forbidHeaders) + checkRequiredHeaders(this, "http_request.headers()", httpRequestTestCase.requireHeaders) if (protocolSupport.requestBodySerialization) { // "If no request body is defined, then no assertions are made about the body of the message." httpRequestTestCase.body.orNull()?.also { body -> 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 f4fbfd5b70a0457860b1bead5143282ee40f2eb9..59953d541844cadaad98a4553ecf7957c84329d6 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 @@ -325,6 +325,16 @@ fun RustType.isCopy(): Boolean = when (this) { else -> false } +/** Returns true if the type implements Eq */ +fun RustType.isEq(): Boolean = when (this) { + is RustType.Integer -> true + is RustType.Bool -> true + is RustType.String -> true + is RustType.Unit -> true + is RustType.Container -> this.member.isEq() + else -> false +} + enum class Visibility { PRIVATE, PUBCRATE, PUBLIC; @@ -546,3 +556,10 @@ class Attribute(val inner: Writable) { } } } + +/** Render all attributes in this list, one after another */ +fun Collection.render(writer: RustWriter) { + for (attr in this) { + attr.render(writer) + } +} 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 a7017b504ef9ad8fa24d510232b2f5fb5a617e06..51df865479af91c1d4bb45c741782fcd6af5616b 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 @@ -92,7 +92,7 @@ fun containerDefaultMetadata( model: Model, additionalAttributes: List = emptyList(), ): RustMetadata { - val defaultDerives = setOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone) + val derives = mutableSetOf(RuntimeType.Debug, RuntimeType.PartialEq, RuntimeType.Clone) val isSensitive = shape.hasTrait() || // Checking the shape's direct members for the sensitive trait should suffice. @@ -101,22 +101,17 @@ fun containerDefaultMetadata( // shape; any sensitive descendant should still be printed as redacted. shape.members().any { it.getMemberTrait(model, SensitiveTrait::class.java).isPresent } - val setOfDerives = if (isSensitive) { - defaultDerives - RuntimeType.Debug - } else { - defaultDerives + if (isSensitive) { + derives.remove(RuntimeType.Debug) } - return RustMetadata( - setOfDerives, - additionalAttributes, - Visibility.PUBLIC, - ) + + return RustMetadata(derives, additionalAttributes, Visibility.PUBLIC) } /** * The base metadata supports a set of attributes that are used by generators to decorate code. * - * By default we apply `#[non_exhaustive]` in [additionalAttributes] only to client structures since breaking model + * By default, we apply `#[non_exhaustive]` in [additionalAttributes] only to client structures since breaking model * changes are fine when generating server code. */ class BaseSymbolMetadataProvider( diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/AllowLintsCustomization.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/AllowLintsCustomization.kt index a06ff50a281921d7578d3203517d45269e90eff6..27e4598246b100810826a1755031843edb6c91e6 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/AllowLintsCustomization.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/AllowLintsCustomization.kt @@ -34,7 +34,7 @@ private val allowedClippyLints = listOf( "should_implement_trait", // Protocol tests use silly names like `baz`, don't flag that. - // TODO(msrv_upgrade): switch + // TODO(msrv_upgrade): switch upon MSRV upgrade to Rust 1.65 "blacklisted_name", // "disallowed_names", @@ -48,11 +48,10 @@ private val allowedClippyLints = listOf( "needless_return", // For backwards compatibility, we often don't derive Eq - // TODO(msrv_upgrade): enable - // "derive_partial_eq_without_eq", + "derive_partial_eq_without_eq", // Keeping errors small in a backwards compatible way is challenging - // TODO(msrv_upgrade): enable + // TODO(msrv_upgrade): uncomment upon MSRV upgrade to Rust 1.65 // "result_large_err", ) 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 69aca4563081103997b26ad8fd6779db411fb779..e6289d89845c001ec6e2cff163f0efef6a0b75f1 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 @@ -114,10 +114,10 @@ class BuilderGenerator( private val members: List = shape.allMembers.values.toList() private val structureSymbol = symbolProvider.toSymbol(shape) private val builderSymbol = shape.builderSymbol(symbolProvider) - private val baseDerives = structureSymbol.expectRustMetadata().derives + private val metadata = structureSymbol.expectRustMetadata() // Filter out any derive that isn't Debug, PartialEq, or Clone. Then add a Default derive - private val builderDerives = baseDerives.filter { it == RuntimeType.Debug || it == RuntimeType.PartialEq || it == RuntimeType.Clone } + RuntimeType.Default + private val builderDerives = metadata.derives.filter { it == RuntimeType.Debug || it == RuntimeType.PartialEq || it == RuntimeType.Clone } + RuntimeType.Default private val builderName = "Builder" fun render(writer: RustWriter) { @@ -207,6 +207,7 @@ class BuilderGenerator( private fun renderBuilder(writer: RustWriter) { writer.docs("A builder for #D.", structureSymbol) + metadata.additionalAttributes.render(writer) Attribute(derive(builderDerives)).render(writer) writer.rustBlock("pub struct $builderName") { for (member in members) { 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 b2ca5e066fed9cec516d0681d34f547fdb411105..e018147808a06073c4e4cf8703d5fff0fa5ff3e9 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 @@ -650,12 +650,13 @@ class HttpBindingGenerator( let $safeName = $formatted; if !$safeName.is_empty() { let header_value = $safeName; - let header_value = http::header::HeaderValue::try_from(&*header_value).map_err(|err| { + let header_value: #{HeaderValue} = header_value.parse().map_err(|err| { #{invalid_field_error:W} })?; builder = builder.header("$headerName", header_value); } """, + "HeaderValue" to RuntimeType.Http.resolve("HeaderValue"), "invalid_field_error" to renderErrorMessage("header_value"), ) } @@ -698,13 +699,14 @@ class HttpBindingGenerator( isMultiValuedHeader = false, ) }; - let header_value = http::header::HeaderValue::try_from(&*header_value).map_err(|err| { + let header_value: #{HeaderValue} = header_value.parse().map_err(|err| { #{invalid_header_value:W} })?; builder = builder.header(header_name, header_value); } """, + "HeaderValue" to RuntimeType.Http.resolve("HeaderValue"), "invalid_header_name" to OperationBuildError(runtimeConfig).invalidField(memberName) { rust("""format!("`{k}` cannot be used as a header name: {err}")""") }, diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt index f05e542381d71090dd9e92d43fdb0e7418033118..a09ca9f10c40d358f1b4f3368762b1f5844b8732 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt @@ -105,7 +105,7 @@ object TestWorkspace { // help rust select the right version when we run cargo test // TODO(https://github.com/awslabs/smithy-rs/issues/2048): load this from the msrv property using a // method as we do for runtime crate versions - "[toolchain]\nchannel = \"1.62.1\"\n", + "[toolchain]\nchannel = \"1.63.0\"\n", ) // ensure there at least an empty lib.rs file to avoid broken crates newProject.resolve("src").mkdirs() diff --git a/gradle.properties b/gradle.properties index bd7ac7f6c8d91a4701f8132557c090cf51e9acc7..8f0bc938131d742996e0ed2b578c9aaea2529fa0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ # # Rust MSRV (entered into the generated README) -rust.msrv=1.62.1 +rust.msrv=1.63.0 org.gradle.jvmargs=-Xmx1024M diff --git a/rust-runtime/aws-smithy-async/src/lib.rs b/rust-runtime/aws-smithy-async/src/lib.rs index 6cd95109e271a774439b7603bd4102517963bed7..b6b4951afc2c6ccaee975b093700132830a1ca28 100644 --- a/rust-runtime/aws-smithy-async/src/lib.rs +++ b/rust-runtime/aws-smithy-async/src/lib.rs @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_debug_implementations, missing_docs, diff --git a/rust-runtime/aws-smithy-checksums/src/lib.rs b/rust-runtime/aws-smithy-checksums/src/lib.rs index ce422fe5ee948cd5f047c62a249b89e4f0131a09..95789ad7c1ee4366c7d7cd50790b9ffd7b9e9f13 100644 --- a/rust-runtime/aws-smithy-checksums/src/lib.rs +++ b/rust-runtime/aws-smithy-checksums/src/lib.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] + //! Checksum calculation and verification callbacks. use crate::error::UnknownChecksumAlgorithmError; @@ -379,8 +381,7 @@ mod tests { fn test_checksum_algorithm_returns_error_for_unknown() { let error = "some invalid checksum algorithm" .parse::() - .err() - .expect("it should error"); + .expect_err("it should error"); assert_eq!( "some invalid checksum algorithm", error.checksum_algorithm() diff --git a/rust-runtime/aws-smithy-client/src/lib.rs b/rust-runtime/aws-smithy-client/src/lib.rs index 48126cef0e1fbe6e997b616203c4501de0fadf27..f83c9d895eae564d420a7a1115fcd75e59e833a3 100644 --- a/rust-runtime/aws-smithy-client/src/lib.rs +++ b/rust-runtime/aws-smithy-client/src/lib.rs @@ -14,6 +14,7 @@ //! | `rustls` | Use `rustls` as the HTTP client's TLS implementation | //! | `client-hyper` | Use `hyper` to handle HTTP requests | +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_debug_implementations, missing_docs, diff --git a/rust-runtime/aws-smithy-eventstream/src/lib.rs b/rust-runtime/aws-smithy-eventstream/src/lib.rs index 07cb538857774f1daa479f2b9febd882fbff2171..594be5d3c9b2d4ed13ceaa38961b44cf8072481a 100644 --- a/rust-runtime/aws-smithy-eventstream/src/lib.rs +++ b/rust-runtime/aws-smithy-eventstream/src/lib.rs @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_debug_implementations, /*missing_docs, diff --git a/rust-runtime/aws-smithy-http-server-python/src/lib.rs b/rust-runtime/aws-smithy-http-server-python/src/lib.rs index b8efefe03f0a49083c698f14e83d03a2d4e4e3fc..17b7a96a0354a64cd5d25deb412646ddee0d73be 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/lib.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/lib.rs @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] #![cfg_attr(docsrs, feature(doc_cfg))] //! Rust/Python bindings, runtime and utilities. diff --git a/rust-runtime/aws-smithy-http-server-python/src/middleware/pytests/layer.rs b/rust-runtime/aws-smithy-http-server-python/src/middleware/pytests/layer.rs index 118b4e7cf8b1ea05c88c0cbae31fa651ffbcff94..506e5a6c20830a1a05cf7b23c8ec02405654c0fd 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/middleware/pytests/layer.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/middleware/pytests/layer.rs @@ -253,6 +253,7 @@ fn simple_request(body: &'static str) -> Request { .expect("could not create request") } +#[allow(clippy::type_complexity)] fn spawn_service( layer: L, ) -> ( @@ -306,7 +307,7 @@ fn py_handler(code: &str) -> PyMiddlewareHandler { .get_item("middleware") .expect("your handler must be named `middleware`") .into(); - Ok::<_, PyErr>(PyMiddlewareHandler::new(py, handler)?) + PyMiddlewareHandler::new(py, handler) }) .unwrap() } diff --git a/rust-runtime/aws-smithy-http-server-python/src/tls/listener.rs b/rust-runtime/aws-smithy-http-server-python/src/tls/listener.rs index 345e0e24ab93df9bb4fdecc85346006a2d4031f1..fb4f759f8986fc6acb20afb5d079a7db12d92aa6 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/tls/listener.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/tls/listener.rs @@ -214,7 +214,7 @@ mod tests { fn client_config_with_cert(cert: &rcgen::Certificate) -> ClientConfig { let mut roots = RootCertStore::empty(); - roots.add_parsable_certificates(&vec![cert.serialize_der().unwrap()]); + roots.add_parsable_certificates(&[cert.serialize_der().unwrap()]); ClientConfig::builder() .with_safe_defaults() .with_root_certificates(roots) @@ -223,7 +223,7 @@ mod tests { fn cert_with_invalid_date() -> rcgen::Certificate { let mut params = rcgen::CertificateParams::new(vec!["localhost".to_string()]); - params.not_after = rcgen::date_time_ymd(1970, 01, 01); + params.not_after = rcgen::date_time_ymd(1970, 1, 1); rcgen::Certificate::from_params(params).unwrap() } diff --git a/rust-runtime/aws-smithy-http-server-python/src/util.rs b/rust-runtime/aws-smithy-http-server-python/src/util.rs index df0b8eafc56bca933e63a97b913590dbb4e4ecda..4cac7f06d27030d91f6631409f0aca846acef6f4 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/util.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/util.rs @@ -130,6 +130,7 @@ async def async_func(): }) } + #[allow(clippy::bool_assert_comparison)] #[test] fn check_if_is_optional_of() -> PyResult<()> { pyo3::prepare_freethreaded_python(); diff --git a/rust-runtime/aws-smithy-http-server/src/lib.rs b/rust-runtime/aws-smithy-http-server/src/lib.rs index 804b00d8a30b0e2579cc233f502040b63b5e034a..6031c53e2a20a10fea35be121dd0c44d48738d49 100644 --- a/rust-runtime/aws-smithy-http-server/src/lib.rs +++ b/rust-runtime/aws-smithy-http-server/src/lib.rs @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] #![cfg_attr(docsrs, feature(doc_cfg))] //! HTTP server runtime and utilities, loosely based on [axum]. diff --git a/rust-runtime/aws-smithy-http-tower/src/lib.rs b/rust-runtime/aws-smithy-http-tower/src/lib.rs index d2a1c546033631a0538a0ccaddeffb82977c5b20..92b60c27029ce66e916d318c59a65ee29cce33f1 100644 --- a/rust-runtime/aws-smithy-http-tower/src/lib.rs +++ b/rust-runtime/aws-smithy-http-tower/src/lib.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] + pub mod dispatch; pub mod map_request; pub mod parse_response; diff --git a/rust-runtime/aws-smithy-http/src/body.rs b/rust-runtime/aws-smithy-http/src/body.rs index 5e9b4fbf2d7ed611a126640f7c50a4fd3439ed4f..8fea913b2ba81f8b09442261e1b0b4a8a42ff460 100644 --- a/rust-runtime/aws-smithy-http/src/body.rs +++ b/rust-runtime/aws-smithy-http/src/body.rs @@ -277,6 +277,7 @@ mod test { assert_eq!(SdkBody::from("").size_hint().exact(), Some(0)); } + #[allow(clippy::bool_assert_comparison)] #[test] fn valid_eos() { assert_eq!(SdkBody::from("hello").is_end_stream(), false); diff --git a/rust-runtime/aws-smithy-http/src/event_stream/sender.rs b/rust-runtime/aws-smithy-http/src/event_stream/sender.rs index 8ecc1b7fd4f593e4847c6ba5e8da15032b8dafa0..fb7af53714bacce6a499244d808bcad35fdf74cf 100644 --- a/rust-runtime/aws-smithy-http/src/event_stream/sender.rs +++ b/rust-runtime/aws-smithy-http/src/event_stream/sender.rs @@ -228,9 +228,7 @@ mod tests { type Input = TestServiceError; fn marshall(&self, _input: Self::Input) -> Result { - Err(Message::read_from(&b""[..]) - .err() - .expect("this should always fail")) + Err(Message::read_from(&b""[..]).expect_err("this should always fail")) } } diff --git a/rust-runtime/aws-smithy-http/src/lib.rs b/rust-runtime/aws-smithy-http/src/lib.rs index 54449bf38ef118ca37a678aa90a4ef3b3abc6249..8c577a2656176b1dfd0003c77e658b69217e03a2 100644 --- a/rust-runtime/aws-smithy-http/src/lib.rs +++ b/rust-runtime/aws-smithy-http/src/lib.rs @@ -15,6 +15,7 @@ //! | `rt-tokio` | Provides features that are dependent on `tokio` including the `ByteStream::from_path` util | //! | `event-stream` | Provides Sender/Receiver implementations for Event Stream codegen. | +#![allow(clippy::derive_partial_eq_without_eq)] #![cfg_attr(docsrs, feature(doc_cfg))] pub mod body; diff --git a/rust-runtime/aws-smithy-json/src/lib.rs b/rust-runtime/aws-smithy-json/src/lib.rs index 58da71b621bdfd70b19ca7de4e2f880369ca2f2c..a4e6904924ff15626fd50cc7be7742480d66322b 100644 --- a/rust-runtime/aws-smithy-json/src/lib.rs +++ b/rust-runtime/aws-smithy-json/src/lib.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] + //! JSON Abstractions for Smithy pub mod deserialize; diff --git a/rust-runtime/aws-smithy-query/src/lib.rs b/rust-runtime/aws-smithy-query/src/lib.rs index 3b9d57a9d020cae10da5d074a8d4e3d4082e397d..26e5ab50bfee3642707090f9c672f71463034629 100644 --- a/rust-runtime/aws-smithy-query/src/lib.rs +++ b/rust-runtime/aws-smithy-query/src/lib.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] + //! Abstractions for the Smithy AWS Query protocol use aws_smithy_types::date_time::{DateTimeFormatError, Format}; diff --git a/rust-runtime/aws-smithy-types-convert/src/lib.rs b/rust-runtime/aws-smithy-types-convert/src/lib.rs index 4487db52b66335e7caf31e6b51f03892510c13fa..c18ebec8e3108f7fdb46c1cf1dd54ff8ba1eaa97 100644 --- a/rust-runtime/aws-smithy-types-convert/src/lib.rs +++ b/rust-runtime/aws-smithy-types-convert/src/lib.rs @@ -5,6 +5,7 @@ //! Conversions between `aws-smithy-types` and the types of frequently used Rust libraries. +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_docs, rustdoc::missing_crate_level_docs, diff --git a/rust-runtime/aws-smithy-types/benches/base64.rs b/rust-runtime/aws-smithy-types/benches/base64.rs index d29654b0591cc5b2d6a4108031ce048b1c408972..0539c190ff27b2e00a81abf1e65dfc3ad73932a9 100644 --- a/rust-runtime/aws-smithy-types/benches/base64.rs +++ b/rust-runtime/aws-smithy-types/benches/base64.rs @@ -4,7 +4,6 @@ */ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; -use rand; use rand::distributions::{Alphanumeric, DistString}; /// Generates a random string of a given length @@ -155,6 +154,7 @@ mod handrolled_base64 { } /// Failure to decode a base64 value. + #[allow(clippy::enum_variant_names)] #[derive(Debug, Clone, Eq, PartialEq)] #[non_exhaustive] pub enum DecodeError { diff --git a/rust-runtime/aws-smithy-types/src/lib.rs b/rust-runtime/aws-smithy-types/src/lib.rs index 1e45b9418339135cfb05b340b3cec8394809a53c..39d91c75becccefda0c871e587d1a5824360516a 100644 --- a/rust-runtime/aws-smithy-types/src/lib.rs +++ b/rust-runtime/aws-smithy-types/src/lib.rs @@ -5,6 +5,7 @@ //! Protocol-agnostic types for smithy-rs. +#![allow(clippy::derive_partial_eq_without_eq)] #![warn( missing_docs, rustdoc::missing_crate_level_docs, diff --git a/rust-runtime/aws-smithy-xml/src/lib.rs b/rust-runtime/aws-smithy-xml/src/lib.rs index f9d4e990ced227fe00d1a607c0efc080f89e18be..fcd414470081f6ae25e1707e4c28c55047b163b1 100644 --- a/rust-runtime/aws-smithy-xml/src/lib.rs +++ b/rust-runtime/aws-smithy-xml/src/lib.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![allow(clippy::derive_partial_eq_without_eq)] + //! Abstractions for Smithy //! [XML Binding Traits](https://awslabs.github.io/smithy/1.0/spec/core/xml-traits.html) pub mod decode; diff --git a/rust-runtime/inlineable/src/endpoint_lib/host.rs b/rust-runtime/inlineable/src/endpoint_lib/host.rs index 41dc029122b398aeda04c23770edea9fd8575daf..4c4168437b434896e01cdff9f13f489c630240d7 100644 --- a/rust-runtime/inlineable/src/endpoint_lib/host.rs +++ b/rust-runtime/inlineable/src/endpoint_lib/host.rs @@ -40,6 +40,7 @@ mod test { super::is_valid_host_label(label, allow_dots, &mut DiagnosticCollector::new()) } + #[allow(clippy::bool_assert_comparison)] #[test] fn basic_cases() { assert_eq!(is_valid_host_label("", false), false); @@ -57,6 +58,7 @@ mod test { ); } + #[allow(clippy::bool_assert_comparison)] #[test] fn start_bounds() { assert_eq!(is_valid_host_label("-foo", false), false); diff --git a/rust-runtime/inlineable/src/endpoint_lib/parse_url.rs b/rust-runtime/inlineable/src/endpoint_lib/parse_url.rs index bd7862aa9438ffe1241513bdb5a242d6f17a7426..5e437c9bfe3816a28cec315a3838124a22638a51 100644 --- a/rust-runtime/inlineable/src/endpoint_lib/parse_url.rs +++ b/rust-runtime/inlineable/src/endpoint_lib/parse_url.rs @@ -71,6 +71,7 @@ mod test { use super::*; use crate::endpoint_lib::diagnostic::DiagnosticCollector; + #[allow(clippy::bool_assert_comparison)] #[test] fn parse_simple_url() { let url = "https://control.vpce-1a2b3c4d-5e6f.s3.us-west-2.vpce.amazonaws.com"; @@ -92,6 +93,7 @@ mod test { assert_eq!(url.scheme(), "https"); } + #[allow(clippy::bool_assert_comparison)] #[test] fn parse_url_with_port() { let url = "http://localhost:8000/path"; diff --git a/rust-runtime/inlineable/src/endpoint_lib/partition.rs b/rust-runtime/inlineable/src/endpoint_lib/partition.rs index 25bec52d952eaf9f2c7976f71ad4339a15cdb93e..55b97a21d2669e4626046ab5f3373e9aac5b432b 100644 --- a/rust-runtime/inlineable/src/endpoint_lib/partition.rs +++ b/rust-runtime/inlineable/src/endpoint_lib/partition.rs @@ -574,8 +574,10 @@ mod test { #[test] fn resolve_partitions() { let mut resolver = PartitionResolver::empty(); - let mut new_suffix = PartitionOutputOverride::default(); - new_suffix.dns_suffix = Some("mars.aws".into()); + let new_suffix = PartitionOutputOverride { + dns_suffix: Some("mars.aws".into()), + ..Default::default() + }; resolver.add_partition(PartitionMetadata { id: "aws".into(), region_regex: Regex::new("^(us|eu|ap|sa|ca|me|af)-\\w+-\\d+$").unwrap(), diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 77c704ff6bf20373540dbb667941b7e08c40ab5f..6a423bf4348ca376abe2ff11667c5f3f734112c8 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.62.1" +channel = "1.63.0" diff --git a/tools/ci-build/Dockerfile b/tools/ci-build/Dockerfile index 38dd3a50d12ea6452922c14e9cc1d3dc32d87a5a..bfee1652814a991b795e107061ccdeee3f19c5c9 100644 --- a/tools/ci-build/Dockerfile +++ b/tools/ci-build/Dockerfile @@ -6,7 +6,7 @@ # This is the base Docker build image used by CI ARG base_image=public.ecr.aws/amazonlinux/amazonlinux:2 -ARG rust_stable_version=1.62.1 +ARG rust_stable_version=1.63.0 ARG rust_nightly_version=nightly-2022-11-16 FROM ${base_image} AS bare_base_image