From 92952cbe511bb48c10c268beff3d485fa9f03f8f Mon Sep 17 00:00:00 2001 From: Zelda Hessler Date: Thu, 16 Mar 2023 16:58:14 -0500 Subject: [PATCH] Update MSRV to 1.66.1 (#2468) * update: MSRV to 1.66.1 * add: CHANGELOG.next.toml entry * update: Dockerfile too * fix: clippy lints * fix: sigv4 event_stream.rs clippy lint update: codegen clippy lint allowlist * fix: doc lint that's nightly only add: docs for aws-smithy-http add: docs for aws-smithy-client add: docs for aws-smithy-async * add: more missing docs. * fix: add more missing docs * remove: unnecessary & in HttpBindingGenerator fix: lint name * fix: another doc import * fix: test broken by changing compiler error * fix: even more lints\nadd: lint warns to all smithy runtime crates * fix: broken doc links * fix: clippy bug * fix: don't use modules named lib in codegen tests * fix: the paginator_canary.rs unnecessary cast --- .github/workflows/ci.yml | 2 +- .github/workflows/claim-crate-names.yml | 2 +- .github/workflows/pull-request-bot.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/update-sdk-next.yml | 2 +- CHANGELOG.next.toml | 12 +++ aws/rust-runtime/aws-config/Cargo.toml | 2 +- .../aws-config/src/imds/credentials.rs | 5 +- .../aws-config/src/meta/credentials/chain.rs | 10 +-- .../aws-config/src/profile/parser.rs | 8 +- .../aws-config/src/profile/parser/source.rs | 6 +- .../aws-sigv4/src/event_stream.rs | 2 +- aws/rust-runtime/aws-sigv4/src/sign.rs | 2 +- aws/rust-runtime/aws-types/build.rs | 4 +- aws/sdk/integration-tests/s3/Cargo.toml | 2 +- .../tests/no-rustls-in-dependency.rs | 2 +- .../generators/ClientEnumGeneratorTest.kt | 12 +-- .../customizations/AllowLintsCustomization.kt | 9 +-- .../generators/http/HttpBindingGenerator.kt | 2 +- .../smithy/rust/codegen/core/testutil/Rust.kt | 2 +- .../codegen/core/rustlang/RustWriterTest.kt | 78 ++++++++++--------- .../generators/StructureGeneratorTest.kt | 78 +++++++++---------- .../RecursiveShapesIntegrationTest.kt | 3 +- gradle.properties | 2 +- rust-runtime/aws-smithy-async/src/lib.rs | 4 +- rust-runtime/aws-smithy-checksums/src/lib.rs | 16 ++-- .../aws-smithy-client/src/erase/boxclone.rs | 2 +- .../aws-smithy-client/src/hyper_ext.rs | 24 +++--- rust-runtime/aws-smithy-client/src/lib.rs | 22 ++++-- rust-runtime/aws-smithy-client/src/retry.rs | 4 +- rust-runtime/aws-smithy-client/src/timeout.rs | 4 +- .../aws-smithy-eventstream/src/buf.rs | 4 +- .../aws-smithy-eventstream/src/buf/count.rs | 6 +- .../aws-smithy-eventstream/src/buf/crc.rs | 14 ++-- .../aws-smithy-eventstream/src/lib.rs | 6 +- rust-runtime/aws-smithy-http-auth/src/lib.rs | 7 +- .../aws-smithy-http-auth/src/location.rs | 2 +- .../src/pytests/bytestream.rs | 2 +- .../aws-smithy-http-server/src/protocols.rs | 4 +- rust-runtime/aws-smithy-http-tower/src/lib.rs | 6 ++ rust-runtime/aws-smithy-http/Cargo.toml | 4 +- rust-runtime/aws-smithy-http/src/body.rs | 13 ++++ .../aws-smithy-http/src/byte_stream.rs | 4 + .../src/byte_stream/bytestream_util.rs | 20 ++--- .../aws-smithy-http/src/byte_stream/error.rs | 2 + .../aws-smithy-http/src/connection.rs | 60 ++++++++------ rust-runtime/aws-smithy-http/src/endpoint.rs | 10 +++ .../aws-smithy-http/src/endpoint/error.rs | 4 + .../src/endpoint/middleware.rs | 3 + .../aws-smithy-http/src/event_stream.rs | 1 + .../src/event_stream/receiver.rs | 1 + .../src/event_stream/sender.rs | 3 + rust-runtime/aws-smithy-http/src/header.rs | 21 +++-- rust-runtime/aws-smithy-http/src/http.rs | 2 + rust-runtime/aws-smithy-http/src/label.rs | 5 ++ rust-runtime/aws-smithy-http/src/lib.rs | 7 ++ .../aws-smithy-http/src/middleware.rs | 3 + rust-runtime/aws-smithy-http/src/operation.rs | 6 ++ .../aws-smithy-http/src/operation/error.rs | 2 + .../aws-smithy-http/src/property_bag.rs | 10 ++- rust-runtime/aws-smithy-http/src/query.rs | 10 ++- .../aws-smithy-http/src/query_writer.rs | 1 + rust-runtime/aws-smithy-http/src/response.rs | 11 ++- rust-runtime/aws-smithy-http/src/result.rs | 7 -- rust-runtime/aws-smithy-http/src/retry.rs | 1 + .../aws-smithy-json/src/deserialize.rs | 11 ++- .../aws-smithy-json/src/deserialize/token.rs | 6 +- rust-runtime/aws-smithy-json/src/escape.rs | 4 +- rust-runtime/aws-smithy-json/src/lib.rs | 7 ++ rust-runtime/aws-smithy-json/src/serialize.rs | 4 +- .../aws-smithy-protocol-test/src/lib.rs | 21 +++-- .../src/urlencoded.rs | 2 +- .../aws-smithy-protocol-test/src/xml.rs | 14 ++-- rust-runtime/aws-smithy-query/src/lib.rs | 14 +++- .../aws-smithy-runtime-api/src/lib.rs | 9 +++ .../src/retries/rate_limiting.rs | 2 + .../src/retries/rate_limiting/error.rs | 4 + .../src/retries/rate_limiting/token.rs | 5 +- rust-runtime/aws-smithy-runtime/src/lib.rs | 7 ++ .../aws-smithy-types-convert/src/lib.rs | 5 +- .../aws-smithy-types/src/date_time/format.rs | 2 +- rust-runtime/aws-smithy-types/src/lib.rs | 2 +- rust-runtime/aws-smithy-xml/src/decode.rs | 4 +- rust-runtime/aws-smithy-xml/src/escape.rs | 2 +- rust-runtime/aws-smithy-xml/src/lib.rs | 7 ++ rust-runtime/aws-smithy-xml/src/unescape.rs | 2 +- .../tests/handwritten_parsers.rs | 2 +- rust-toolchain.toml | 2 +- tools/ci-build/Dockerfile | 2 +- tools/ci-build/changelogger/tests/e2e_test.rs | 4 +- tools/ci-build/difftags/src/html.rs | 2 +- tools/ci-build/difftags/src/page.rs | 4 +- tools/ci-build/publisher/src/publish.rs | 2 +- tools/ci-build/publisher/src/sort.rs | 6 +- .../subcommand/generate_version_manifest.rs | 2 +- .../src/subcommand/hydrate_readme.rs | 2 +- tools/ci-build/sdk-lints/src/anchor.rs | 11 +-- tools/ci-build/sdk-versioner/src/main.rs | 6 +- .../smithy-rs-tool-common/src/changelog.rs | 2 +- .../src/latest/paginator_canary.rs | 2 +- .../ci-cdk/canary-runner/src/build_bundle.rs | 6 +- tools/echo-server/Cargo.lock | 4 +- tools/echo-server/Cargo.toml | 2 +- 103 files changed, 479 insertions(+), 305 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52b54efd45..048e577fcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ on: required: false env: - rust_version: 1.63.0 + rust_version: 1.66.1 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 63b5eac307..ef24446bb7 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.63.0 + rust_version: 1.66.1 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 131939fcb0..6d22213eb5 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.63.0 + rust_version: 1.66.1 rust_toolchain_components: clippy,rustfmt apt_dependencies: libssl-dev gnuplot jq diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bcc1cf22ab..52ddfdfe7a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ concurrency: cancel-in-progress: true env: - rust_version: 1.63.0 + rust_version: 1.66.1 name: Release smithy-rs run-name: ${{ github.workflow }} ${{ inputs.semantic_version }} (${{ inputs.commit_sha }}) - ${{ inputs.dry_run && 'Dry run' || 'Production run' }} diff --git a/.github/workflows/update-sdk-next.yml b/.github/workflows/update-sdk-next.yml index fd6082351e..c96b09b73f 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.63.0 + toolchain: 1.66.1 - name: Delete old SDK run: | - name: Generate a fresh SDK diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 14f803e8e3..0a4675a4cd 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -326,3 +326,15 @@ be reused. references = ["aws-sdk-rust#160", "smithy-rs#2445"] meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" } author = "rcoh" + +[[aws-sdk-rust]] +message = "Update MSRV to 1.66.1" +references = ["smithy-rs#2467"] +meta = { "breaking" = true, "tada" = true, "bug" = false } +author = "Velfi" + +[[smithy-rs]] +message = "Update MSRV to 1.66.1" +references = ["smithy-rs#2467"] +meta = { "breaking" = true, "tada" = true, "bug" = false, "target" = "all" } +author = "Velfi" diff --git a/aws/rust-runtime/aws-config/Cargo.toml b/aws/rust-runtime/aws-config/Cargo.toml index 87fb754a01..8c9f39381e 100644 --- a/aws/rust-runtime/aws-config/Cargo.toml +++ b/aws/rust-runtime/aws-config/Cargo.toml @@ -28,7 +28,7 @@ aws-smithy-http-tower = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-http-to aws-smithy-json = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-json" } aws-smithy-types = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-types" } aws-types = { path = "../../sdk/build/aws-sdk/sdk/aws-types" } -hyper = { version = "0.14.12", default-features = false } +hyper = { version = "0.14.25", default-features = false } time = { version = "0.3.4", features = ["parsing"] } tokio = { version = "1.13.1", features = ["sync"] } tracing = { version = "0.1" } diff --git a/aws/rust-runtime/aws-config/src/imds/credentials.rs b/aws/rust-runtime/aws-config/src/imds/credentials.rs index 8cd3df7d0e..c260ba51f1 100644 --- a/aws/rust-runtime/aws-config/src/imds/credentials.rs +++ b/aws/rust-runtime/aws-config/src/imds/credentials.rs @@ -452,11 +452,10 @@ mod test { sleeper.sleep(std::time::Duration::from_millis(100)), ); match timeout.await { - Ok(_) => assert!(false, "provide_credentials completed before timeout future"), + Ok(_) => panic!("provide_credentials completed before timeout future"), Err(_err) => match provider.fallback_on_interrupt() { Some(actual) => assert_eq!(actual, expected), - None => assert!( - false, + None => panic!( "provide_credentials timed out and no credentials returned from fallback_on_interrupt" ), }, diff --git a/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs b/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs index 02ae424c25..193d9fb1ec 100644 --- a/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs +++ b/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs @@ -174,11 +174,10 @@ mod tests { tokio::time::sleep(Duration::from_millis(300)), ); match timeout.await { - Ok(_) => assert!(false, "provide_credentials completed before timeout future"), + Ok(_) => panic!("provide_credentials completed before timeout future"), Err(_err) => match chain.fallback_on_interrupt() { Some(actual) => assert_eq!(actual, expected), - None => assert!( - false, + None => panic!( "provide_credentials timed out and no credentials returned from fallback_on_interrupt" ), }, @@ -208,11 +207,10 @@ mod tests { tokio::time::sleep(Duration::from_millis(100)), ); match timeout.await { - Ok(_) => assert!(false, "provide_credentials completed before timeout future"), + Ok(_) => panic!("provide_credentials completed before timeout future"), Err(_err) => match chain.fallback_on_interrupt() { Some(actual) => assert_eq!(actual, expected), - None => assert!( - false, + None => panic!( "provide_credentials timed out and no credentials returned from fallback_on_interrupt" ), }, diff --git a/aws/rust-runtime/aws-config/src/profile/parser.rs b/aws/rust-runtime/aws-config/src/profile/parser.rs index 0692bf376f..6d6dc204a3 100644 --- a/aws/rust-runtime/aws-config/src/profile/parser.rs +++ b/aws/rust-runtime/aws-config/src/profile/parser.rs @@ -334,14 +334,14 @@ mod test { fn flatten(profile: ProfileSet) -> HashMap> { profile .profiles - .into_iter() - .map(|(_name, profile)| { + .into_values() + .map(|profile| { ( profile.name, profile .properties - .into_iter() - .map(|(_, prop)| (prop.key, prop.value)) + .into_values() + .map(|prop| (prop.key, prop.value)) .collect(), ) }) diff --git a/aws/rust-runtime/aws-config/src/profile/parser/source.rs b/aws/rust-runtime/aws-config/src/profile/parser/source.rs index d626394aa1..1b859fcee9 100644 --- a/aws/rust-runtime/aws-config/src/profile/parser/source.rs +++ b/aws/rust-runtime/aws-config/src/profile/parser/source.rs @@ -216,7 +216,7 @@ mod tests { // ~ is only expanded as a single component (currently) let path = "~aws/config"; assert_eq!( - expand_home(&path, false, &None).to_str().unwrap(), + expand_home(path, false, &None).to_str().unwrap(), "~aws/config" ); } @@ -336,7 +336,7 @@ mod tests { fn test_expand_home() { let path = "~/.aws/config"; assert_eq!( - expand_home(&path, false, &Some("/user/foo".to_string())) + expand_home(path, false, &Some("/user/foo".to_string())) .to_str() .unwrap(), "/user/foo/.aws/config" @@ -366,7 +366,7 @@ mod tests { fn test_expand_home_windows() { let path = "~/.aws/config"; assert_eq!( - expand_home(&path, true, &Some("C:\\Users\\name".to_string()),) + expand_home(path, true, &Some("C:\\Users\\name".to_string()),) .to_str() .unwrap(), "C:\\Users\\name\\.aws\\config" diff --git a/aws/rust-runtime/aws-sigv4/src/event_stream.rs b/aws/rust-runtime/aws-sigv4/src/event_stream.rs index 349ba919f0..a8da19ab03 100644 --- a/aws/rust-runtime/aws-sigv4/src/event_stream.rs +++ b/aws/rust-runtime/aws-sigv4/src/event_stream.rs @@ -74,7 +74,7 @@ fn calculate_string_to_sign( let mut date_buffer = Vec::new(); write_headers_to(&[date_header], &mut date_buffer).unwrap(); writeln!(sts, "{}", sha256_hex_string(&date_buffer)).unwrap(); - write!(sts, "{}", sha256_hex_string(&message_payload)).unwrap(); + write!(sts, "{}", sha256_hex_string(message_payload)).unwrap(); sts } diff --git a/aws/rust-runtime/aws-sigv4/src/sign.rs b/aws/rust-runtime/aws-sigv4/src/sign.rs index a140f6e955..43e9da1ac1 100644 --- a/aws/rust-runtime/aws-sigv4/src/sign.rs +++ b/aws/rust-runtime/aws-sigv4/src/sign.rs @@ -84,7 +84,7 @@ mod tests { #[test] fn sign_payload_empty_string() { let expected = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; - let actual = sha256_hex_string(&[]); + let actual = sha256_hex_string([]); assert_eq!(expected, actual); } } diff --git a/aws/rust-runtime/aws-types/build.rs b/aws/rust-runtime/aws-types/build.rs index 533271f769..593ac054b3 100644 --- a/aws/rust-runtime/aws-types/build.rs +++ b/aws/rust-runtime/aws-types/build.rs @@ -11,8 +11,8 @@ use std::path::Path; fn generate_build_vars(output_path: &Path) { let rust_version = rustc_version::version().expect("Could not retrieve rustc version"); - let mut f = File::create(&output_path.join("build_env.rs")) - .expect("Could not create build environment"); + let mut f = + File::create(output_path.join("build_env.rs")).expect("Could not create build environment"); f.write_all(format!("const RUST_VERSION: &str = \"{}\";", rust_version).as_bytes()) .expect("Unable to write rust version"); f.flush().expect("failed to flush"); diff --git a/aws/sdk/integration-tests/s3/Cargo.toml b/aws/sdk/integration-tests/s3/Cargo.toml index 7da45d554a..4a5b1f4a29 100644 --- a/aws/sdk/integration-tests/s3/Cargo.toml +++ b/aws/sdk/integration-tests/s3/Cargo.toml @@ -30,7 +30,7 @@ futures-util = "0.3.25" hdrhistogram = "7.5.2" http = "0.2.3" http-body = "0.4.5" -hyper = "0.14.12" +hyper = "0.14.25" serde_json = "1" smol = "1.2" tempfile = "3" diff --git a/aws/sdk/integration-tests/using-native-tls-instead-of-rustls/tests/no-rustls-in-dependency.rs b/aws/sdk/integration-tests/using-native-tls-instead-of-rustls/tests/no-rustls-in-dependency.rs index dddeebc479..1df97865db 100644 --- a/aws/sdk/integration-tests/using-native-tls-instead-of-rustls/tests/no-rustls-in-dependency.rs +++ b/aws/sdk/integration-tests/using-native-tls-instead-of-rustls/tests/no-rustls-in-dependency.rs @@ -22,7 +22,7 @@ async fn list_buckets() -> Result<(), aws_sdk_s3::Error> { #[should_panic = "error: package ID specification `rustls` did not match any packages"] fn test_rustls_is_not_in_dependency_tree() { let cargo_location = std::env::var("CARGO").unwrap(); - let cargo_command = std::process::Command::new(&cargo_location) + let cargo_command = std::process::Command::new(cargo_location) .arg("tree") .arg("--invert") .arg("rustls") diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGeneratorTest.kt index e0cf8f2493..4354033485 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGeneratorTest.kt @@ -29,12 +29,12 @@ class ClientEnumGeneratorTest { "matching_on_enum_should_be_forward_compatible", """ match $enumToMatchOn { - SomeEnum::Variant1 => assert!(false, "expected `Variant3` but got `Variant1`"), - SomeEnum::Variant2 => assert!(false, "expected `Variant3` but got `Variant2`"), - other @ _ if other.as_str() == "Variant3" => assert!(true), - _ => assert!(false, "expected `Variant3` but got `_`"), + SomeEnum::Variant1 => panic!("expected `Variant3` but got `Variant1`"), + SomeEnum::Variant2 => panic!("expected `Variant3` but got `Variant2`"), + other @ _ if other.as_str() == "Variant3" => {}, + _ => panic!("expected `Variant3` but got `_`"), } - """.trimIndent(), + """, ) } project.compileAndTest() @@ -120,7 +120,7 @@ class ClientEnumGeneratorTest { assert_eq!(SomeEnum::from("Unknown"), SomeEnum::UnknownValue); assert_eq!(SomeEnum::from("UnknownValue"), SomeEnum::UnknownValue_); assert_eq!(SomeEnum::from("SomethingNew"), SomeEnum::Unknown(crate::primitives::UnknownVariantValue("SomethingNew".to_owned()))); - """.trimIndent(), + """, ) } project.compileAndTest() 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 27e4598246..43eb40696e 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 @@ -21,7 +21,7 @@ private val allowedClippyLints = listOf( // Sometimes operations are named the same as our module e.g. output leading to `output::output`. "module_inception", - // Currently, we don't recase acronyms in models, e.g. `SSEVersion`. + // Currently, we don't re-case acronyms in models, e.g. `SSEVersion`. "upper_case_acronyms", // Large errors trigger this warning, we are unlikely to optimize this case currently. @@ -34,9 +34,7 @@ private val allowedClippyLints = listOf( "should_implement_trait", // Protocol tests use silly names like `baz`, don't flag that. - // TODO(msrv_upgrade): switch upon MSRV upgrade to Rust 1.65 - "blacklisted_name", - // "disallowed_names", + "disallowed_names", // Forcing use of `vec![]` can make codegen harder in some cases. "vec_init_then_push", @@ -51,8 +49,7 @@ private val allowedClippyLints = listOf( "derive_partial_eq_without_eq", // Keeping errors small in a backwards compatible way is challenging - // TODO(msrv_upgrade): uncomment upon MSRV upgrade to Rust 1.65 - // "result_large_err", + "result_large_err", ) private val allowedRustdocLints = listOf( 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 189362e2cd..d53e09df68 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 @@ -730,7 +730,7 @@ class HttpBindingGenerator( target.isStringShape -> { if (target.hasTrait()) { val func = writer.format(RuntimeType.base64Encode(runtimeConfig)) - "$func(&$targetName)" + "$func($targetName)" } else { quoteValue("$targetName.as_str()") } 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 a18047f335..5f9e612ee7 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 @@ -109,7 +109,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.63.0\"\n", + "[toolchain]\nchannel = \"1.66.1\"\n", ) // ensure there at least an empty lib.rs file to avoid broken crates newProject.resolve("src").mkdirs() diff --git a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriterTest.kt b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriterTest.kt index eb78c76962..3b0ef7c557 100644 --- a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriterTest.kt +++ b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriterTest.kt @@ -19,11 +19,11 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.core.rustlang.Attribute.Companion.deprecated import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.testutil.TestModuleDocProvider +import software.amazon.smithy.rust.codegen.core.testutil.TestWorkspace import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel -import software.amazon.smithy.rust.codegen.core.testutil.compileAndRun import software.amazon.smithy.rust.codegen.core.testutil.compileAndTest -import software.amazon.smithy.rust.codegen.core.testutil.shouldCompile import software.amazon.smithy.rust.codegen.core.testutil.testSymbolProvider +import software.amazon.smithy.rust.codegen.core.testutil.unitTest import software.amazon.smithy.rust.codegen.core.util.lookup class RustWriterTest { @@ -45,7 +45,6 @@ class RustWriterTest { @Test fun `manually created struct`() { - val sut = RustWriter.forModule("lib") val stringShape = StringShape.builder().id("test#Hello").build() val set = SetShape.builder() .id("foo.bar#Records") @@ -59,37 +58,43 @@ class RustWriterTest { val provider = testSymbolProvider(model) val setSymbol = provider.toSymbol(set) val stringSymbol = provider.toSymbol(stringShape) - sut.rustBlock("struct Test") { - write("member: #T,", setSymbol) - write("otherMember: #T,", stringSymbol) - } - val output = sut.toString() - output.shouldCompile() - output shouldContain RustType.HashSet.Type - output shouldContain "struct Test" - output.compileAndRun( - """ - let test = Test { member: ${RustType.HashSet.Namespace}::${RustType.HashSet.Type}::default(), otherMember: "hello".to_string() }; - assert_eq!(test.otherMember, "hello"); - assert_eq!(test.member.is_empty(), true); - """, - ) + + TestWorkspace.testProject(provider) + .unitTest { + rustBlock("struct Test") { + write("member: #T,", setSymbol) + write("other_member: #T,", stringSymbol) + } + + unitTest("test_manually_created_struct") { + rust( + """ + let test = Test { member: ${RustType.HashSet.Namespace}::${RustType.HashSet.Type}::default(), other_member: "hello".to_string() }; + assert_eq!(test.other_member, "hello"); + assert_eq!(test.member.is_empty(), true); + + // If this compiles, then we know the symbol provider resolved the correct type for a set + let _isVec: Vec<_> = test.member; + """, + ) + } + }.compileAndTest(runClippy = true) } @Test fun `generate docs`() { - val sut = RustWriter.forModule("lib") - sut.docs( + val writer = RustWriter.root() + writer.docs( """Top level module documentation |More docs |/* handle weird characters */ |`a backtick` - |[a link](asdf) - """.trimMargin(), + |[a link](some_url) + """, ) - sut.rustBlock("pub fn foo()") { } - sut.compileAndTest() - sut.toString() shouldContain "Top level module" + writer.rustBlock("pub fn foo()") { } + val output = writer.toString() + output shouldContain "/// Top level module" } @Test @@ -100,9 +105,10 @@ class RustWriterTest { """.asSmithyModel() val shape = model.lookup("test#Foo") val symbol = testSymbolProvider(model).toSymbol(shape) - val sut = RustWriter.forModule("lib") - sut.docs("A link! #D", symbol) - sut.toString() shouldContain "/// A link! [`Foo`](crate::test_model::Foo)" + val writer = RustWriter.root() + writer.docs("A link! #D", symbol) + val output = writer.toString() + output shouldContain "/// A link! [`Foo`](crate::test_model::Foo)" } @Test @@ -113,7 +119,7 @@ class RustWriterTest { @Test fun `attributes with comments when using rust`() { - val sut = RustWriter.forModule("lib") + val sut = RustWriter.root() Attribute("foo").render(sut) sut.rust(" // here's an attribute") sut.toString().shouldContain("#[foo]\n// here's an attribute") @@ -121,7 +127,7 @@ class RustWriterTest { @Test fun `attributes with comments when using docs`() { - val sut = RustWriter.forModule("lib") + val sut = RustWriter.root() Attribute("foo").render(sut) sut.docs("here's an attribute") sut.toString().shouldContain("#[foo]\n/// here's an attribute") @@ -129,28 +135,28 @@ class RustWriterTest { @Test fun `deprecated attribute without any field`() { - val sut = RustWriter.forModule("lib") + val sut = RustWriter.root() Attribute.Deprecated.render(sut) sut.toString() shouldContain "#[deprecated]" } @Test fun `deprecated attribute with a note`() { - val sut = RustWriter.forModule("lib") + val sut = RustWriter.root() Attribute(deprecated(note = "custom")).render(sut) sut.toString() shouldContain "#[deprecated(note = \"custom\")]" } @Test fun `deprecated attribute with a since`() { - val sut = RustWriter.forModule("lib") + val sut = RustWriter.root() Attribute(deprecated(since = "1.2.3")).render(sut) sut.toString() shouldContain "#[deprecated(since = \"1.2.3\")]" } @Test fun `deprecated attribute with a note and a since`() { - val sut = RustWriter.forModule("lib") + val sut = RustWriter.root() Attribute(deprecated("1.2.3", "custom")).render(sut) sut.toString() shouldContain "#[deprecated(note = \"custom\", since = \"1.2.3\")]" } @@ -158,7 +164,7 @@ class RustWriterTest { @Test fun `template writables with upper case names`() { val inner = writable { rust("hello") } - val sut = RustWriter.forModule("lib") + val sut = RustWriter.root() sut.rustTemplate( "inner: #{Inner:W}, regular: #{http}", "Inner" to inner, @@ -169,7 +175,7 @@ class RustWriterTest { @Test fun `missing template parameters are enclosed in backticks in the exception message`() { - val sut = RustWriter.forModule("lib") + val sut = RustWriter.root() val exception = assertThrows { sut.rustTemplate( "#{Foo} #{Bar}", diff --git a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGeneratorTest.kt b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGeneratorTest.kt index 86e81c45f9..f765587300 100644 --- a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGeneratorTest.kt +++ b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGeneratorTest.kt @@ -148,39 +148,39 @@ class StructureGeneratorTest { @Test fun `generate a custom debug implementation when the sensitive trait is applied to some members`() { val provider = testSymbolProvider(model, rustReservedWordConfig = rustReservedWordConfig) - val writer = RustWriter.forModule("lib") - val generator = StructureGenerator(model, provider, writer, credentials, emptyList()) - generator.render() - writer.unitTest( - "sensitive_fields_redacted", - """ - let creds = Credentials { - username: Some("not_redacted".to_owned()), - password: Some("don't leak me".to_owned()), - secret_key: Some("don't leak me".to_owned()) - }; - assert_eq!(format!("{:?}", creds), "Credentials { username: Some(\"not_redacted\"), password: \"*** Sensitive Data Redacted ***\", secret_key: \"*** Sensitive Data Redacted ***\" }"); - """, - ) - writer.compileAndTest() + TestWorkspace.testProject().unitTest { + StructureGenerator(model, provider, this, credentials, emptyList()).render() + + this.unitTest( + "sensitive_fields_redacted", + """ + let creds = Credentials { + username: Some("not_redacted".to_owned()), + password: Some("don't leak me".to_owned()), + secret_key: Some("don't leak me".to_owned()) + }; + assert_eq!(format!("{:?}", creds), "Credentials { username: Some(\"not_redacted\"), password: \"*** Sensitive Data Redacted ***\", secret_key: \"*** Sensitive Data Redacted ***\" }"); + """, + ) + }.compileAndTest() } @Test fun `generate a custom debug implementation when the sensitive trait is applied to the struct`() { val provider = testSymbolProvider(model, rustReservedWordConfig = rustReservedWordConfig) - val writer = RustWriter.forModule("lib") - val generator = StructureGenerator(model, provider, writer, secretStructure, emptyList()) - generator.render() - writer.unitTest( - "sensitive_structure_redacted", - """ - let secret_structure = SecretStructure { - secret_field: Some("secret".to_owned()), - }; - assert_eq!(format!("{:?}", secret_structure), "SecretStructure { secret_field: \"*** Sensitive Data Redacted ***\" }"); - """, - ) - writer.compileAndTest() + TestWorkspace.testProject().unitTest { + StructureGenerator(model, provider, this, secretStructure, emptyList()).render() + + this.unitTest( + "sensitive_structure_redacted", + """ + let secret_structure = SecretStructure { + secret_field: Some("secret".to_owned()), + }; + assert_eq!(format!("{:?}", secret_structure), "SecretStructure { secret_field: \"*** Sensitive Data Redacted ***\" }"); + """, + ) + }.compileAndTest() } @Test @@ -242,17 +242,17 @@ class StructureGeneratorTest { @Test fun `documents are optional in structs`() { val provider = testSymbolProvider(model, rustReservedWordConfig = rustReservedWordConfig) - val writer = RustWriter.forModule("lib") - StructureGenerator(model, provider, writer, structWithDoc, emptyList()).render() - - writer.compileAndTest( - """ - let _struct = StructWithDoc { - // This will only compile if the document is optional - doc: None - }; - """, - ) + TestWorkspace.testProject().unitTest { + StructureGenerator(model, provider, this, structWithDoc, emptyList()).render() + rust( + """ + let _struct = StructWithDoc { + // This will only compile if the document is optional + doc: None + }; + """.trimIndent(), + ) + }.compileAndTest() } @Test diff --git a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RecursiveShapesIntegrationTest.kt b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RecursiveShapesIntegrationTest.kt index 8b33c57694..1dfc41795d 100644 --- a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RecursiveShapesIntegrationTest.kt +++ b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/RecursiveShapesIntegrationTest.kt @@ -64,7 +64,8 @@ class RecursiveShapesIntegrationTest { val output = assertThrows { unmodifiedProject.compileAndTest(expectFailure = true) } - output.message shouldContain "has infinite size" + // THIS IS A LOAD-BEARING shouldContain! If the compiler error changes then this will break! + output.message shouldContain "have infinite size" val fixedProject = check(RecursiveShapeBoxer().transform(model)) fixedProject.compileAndTest() diff --git a/gradle.properties b/gradle.properties index fc748a383b..cf9db2779e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ # # Rust MSRV (entered into the generated README) -rust.msrv=1.63.0 +rust.msrv=1.66.1 # To enable debug, swap out the two lines below. # When changing this value, be sure to run `./gradlew --stop` to kill the Gradle daemon. diff --git a/rust-runtime/aws-smithy-async/src/lib.rs b/rust-runtime/aws-smithy-async/src/lib.rs index b6b4951afc..7e106da5db 100644 --- a/rust-runtime/aws-smithy-async/src/lib.rs +++ b/rust-runtime/aws-smithy-async/src/lib.rs @@ -5,9 +5,9 @@ #![allow(clippy::derive_partial_eq_without_eq)] #![warn( - missing_debug_implementations, missing_docs, - rustdoc::all, + rustdoc::missing_crate_level_docs, + unreachable_pub, rust_2018_idioms )] diff --git a/rust-runtime/aws-smithy-checksums/src/lib.rs b/rust-runtime/aws-smithy-checksums/src/lib.rs index 95789ad7c1..9edda514ec 100644 --- a/rust-runtime/aws-smithy-checksums/src/lib.rs +++ b/rust-runtime/aws-smithy-checksums/src/lib.rs @@ -4,6 +4,12 @@ */ #![allow(clippy::derive_partial_eq_without_eq)] +#![warn( + // missing_docs, + rustdoc::missing_crate_level_docs, + unreachable_pub, + rust_2018_idioms +)] //! Checksum calculation and verification callbacks. @@ -64,11 +70,11 @@ impl ChecksumAlgorithm { /// Return the `HttpChecksum` implementor for this algorithm pub fn into_impl(self) -> Box { match self { - Self::Crc32 => Box::new(Crc32::default()), - Self::Crc32c => Box::new(Crc32c::default()), - Self::Md5 => Box::new(Md5::default()), - Self::Sha1 => Box::new(Sha1::default()), - Self::Sha256 => Box::new(Sha256::default()), + Self::Crc32 => Box::::default(), + Self::Crc32c => Box::::default(), + Self::Md5 => Box::::default(), + Self::Sha1 => Box::::default(), + Self::Sha256 => Box::::default(), } } diff --git a/rust-runtime/aws-smithy-client/src/erase/boxclone.rs b/rust-runtime/aws-smithy-client/src/erase/boxclone.rs index e0a2d408f6..1604d448b9 100644 --- a/rust-runtime/aws-smithy-client/src/erase/boxclone.rs +++ b/rust-runtime/aws-smithy-client/src/erase/boxclone.rs @@ -29,7 +29,7 @@ impl Clone for ArcCloneLayer { impl ArcCloneLayer { /// Create a new [`BoxLayer`]. - pub fn new(inner_layer: L) -> Self + pub(crate) fn new(inner_layer: L) -> Self where L: Layer + Send + Sync + 'static, L::Service: Service + Clone + Send + Sync + 'static, diff --git a/rust-runtime/aws-smithy-client/src/hyper_ext.rs b/rust-runtime/aws-smithy-client/src/hyper_ext.rs index f059467829..7032604a78 100644 --- a/rust-runtime/aws-smithy-client/src/hyper_ext.rs +++ b/rust-runtime/aws-smithy-client/src/hyper_ext.rs @@ -144,7 +144,7 @@ fn extract_smithy_connection(capture_conn: &CaptureConnection) -> Option Service> for Adapter where C: Clone + Send + Sync + 'static, - C: tower::Service, + C: Service, C::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, C::Future: Unpin + Send + 'static, C::Error: Into, @@ -236,7 +236,7 @@ fn find_source<'a, E: Error + 'static>(err: &'a (dyn Error + 'static)) -> Option /// Builder for [`hyper_ext::Adapter`](Adapter) /// -/// Unlike a Smithy client, the [`tower::Service`] inside a [`hyper_ext::Adapter`](Adapter) is actually a service that +/// Unlike a Smithy client, the [`Service`] inside a [`hyper_ext::Adapter`](Adapter) is actually a service that /// accepts a `Uri` and returns a TCP stream. Two default implementations of this are provided, one /// that encrypts the stream with `rustls`, the other that encrypts the stream with `native-tls`. /// @@ -270,7 +270,7 @@ impl Builder { pub fn build(self, connector: C) -> Adapter where C: Clone + Send + Sync + 'static, - C: tower::Service, + C: Service, C::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, C::Future: Unpin + Send + 'static, C::Error: Into, @@ -312,7 +312,7 @@ impl Builder { /// Set the async sleep implementation used for timeouts /// /// Calling this is only necessary for testing or to use something other than - /// [`aws_smithy_async::rt::sleep::default_async_sleep`]. + /// [`default_async_sleep`]. pub fn sleep_impl(mut self, sleep_impl: Arc) -> Self { self.sleep_impl = Some(sleep_impl); self @@ -321,7 +321,7 @@ impl Builder { /// Set the async sleep implementation used for timeouts /// /// Calling this is only necessary for testing or to use something other than - /// [`aws_smithy_async::rt::sleep::default_async_sleep`]. + /// [`default_async_sleep`]. pub fn set_sleep_impl( &mut self, sleep_impl: Option>, @@ -421,14 +421,14 @@ mod timeout_middleware { /// Create a new `ConnectTimeout` around `inner`. /// /// Typically, `I` will implement [`hyper::client::connect::Connect`]. - pub fn new(inner: I, sleep: Arc, timeout: Duration) -> Self { + pub(crate) fn new(inner: I, sleep: Arc, timeout: Duration) -> Self { Self { inner, timeout: Some((sleep, timeout)), } } - pub fn no_timeout(inner: I) -> Self { + pub(crate) fn no_timeout(inner: I) -> Self { Self { inner, timeout: None, @@ -437,7 +437,7 @@ mod timeout_middleware { } #[derive(Clone, Debug)] - pub struct HttpReadTimeout { + pub(crate) struct HttpReadTimeout { inner: I, timeout: Option<(Arc, Duration)>, } @@ -446,14 +446,14 @@ mod timeout_middleware { /// Create a new `HttpReadTimeout` around `inner`. /// /// Typically, `I` will implement [`tower::Service>`]. - pub fn new(inner: I, sleep: Arc, timeout: Duration) -> Self { + pub(crate) fn new(inner: I, sleep: Arc, timeout: Duration) -> Self { Self { inner, timeout: Some((sleep, timeout)), } } - pub fn no_timeout(inner: I) -> Self { + pub(crate) fn no_timeout(inner: I) -> Self { Self { inner, timeout: None, @@ -722,7 +722,7 @@ mod test { _cx: &mut Context<'_>, _buf: &mut ReadBuf<'_>, ) -> Poll> { - Poll::Ready(Err(std::io::Error::new( + Poll::Ready(Err(Error::new( ErrorKind::ConnectionReset, "connection reset", ))) @@ -754,7 +754,7 @@ mod test { impl tower::Service for TestConnection where - T: Clone + hyper::client::connect::Connection, + T: Clone + Connection, { type Response = T; type Error = BoxError; diff --git a/rust-runtime/aws-smithy-client/src/lib.rs b/rust-runtime/aws-smithy-client/src/lib.rs index 479641704d..080e5ac9eb 100644 --- a/rust-runtime/aws-smithy-client/src/lib.rs +++ b/rust-runtime/aws-smithy-client/src/lib.rs @@ -16,9 +16,9 @@ #![allow(clippy::derive_partial_eq_without_eq)] #![warn( - missing_debug_implementations, missing_docs, - rustdoc::all, + rustdoc::missing_crate_level_docs, + unreachable_pub, rust_2018_idioms )] @@ -67,7 +67,7 @@ use std::sync::Arc; use timeout::ClientTimeoutParams; pub use timeout::TimeoutLayer; use tower::{Service, ServiceBuilder, ServiceExt}; -use tracing::{debug_span, field, field::display, Instrument}; +use tracing::{debug_span, field, Instrument}; /// Smithy service client. /// @@ -85,8 +85,8 @@ use tracing::{debug_span, field, field::display, Instrument}; /// to the inner service, and then ultimately returning the inner service's response. /// /// With the `hyper` feature enabled, you can construct a `Client` directly from a -/// [`hyper::Client`] using [`hyper_ext::Adapter::builder`]. You can also enable the `rustls` or `native-tls` -/// features to construct a Client against a standard HTTPS endpoint using [`Builder::rustls_connector`] and +/// `hyper::Client` using `hyper_ext::Adapter::builder`. You can also enable the `rustls` or `native-tls` +/// features to construct a Client against a standard HTTPS endpoint using `Builder::rustls_connector` and /// `Builder::native_tls_connector` respectively. #[derive(Debug)] pub struct Client< @@ -206,8 +206,13 @@ where ); let (mut req, parts) = op.into_request_response(); if let Some(metadata) = &parts.metadata { - span.record("operation", &metadata.name()); - span.record("service", &metadata.service()); + // Clippy has a bug related to needless borrows so we need to allow them here + // https://github.com/rust-lang/rust-clippy/issues/9782 + #[allow(clippy::needless_borrow)] + { + span.record("operation", &metadata.name()); + span.record("service", &metadata.service()); + } // This will clone two `Cow::<&'static str>::Borrow`s in the vast majority of cases req.properties_mut().insert(metadata.clone()); } @@ -216,6 +221,7 @@ where let result = async move { check_send_sync(svc).ready().await?.call(op).await } .instrument(span.clone()) .await; + #[allow(clippy::needless_borrow)] match &result { Ok(_) => { span.record("status", &"ok"); @@ -232,7 +238,7 @@ where _ => "error", }, ) - .record("message", &display(DisplayErrorContext(err))); + .record("message", &field::display(DisplayErrorContext(err))); } } result diff --git a/rust-runtime/aws-smithy-client/src/retry.rs b/rust-runtime/aws-smithy-client/src/retry.rs index 10df4ae5fc..2c38807fae 100644 --- a/rust-runtime/aws-smithy-client/src/retry.rs +++ b/rust-runtime/aws-smithy-client/src/retry.rs @@ -198,7 +198,7 @@ impl Default for RequestLocalRetryState { } impl RequestLocalRetryState { - pub fn new() -> Self { + fn new() -> Self { Self::default() } } @@ -219,7 +219,7 @@ struct CrossRequestRetryState { // significantly more complicated for negligible benefit. #[allow(clippy::mutex_atomic)] impl CrossRequestRetryState { - pub fn new(initial_quota: usize) -> Self { + fn new(initial_quota: usize) -> Self { Self { quota_available: Arc::new(Mutex::new(initial_quota)), } diff --git a/rust-runtime/aws-smithy-client/src/timeout.rs b/rust-runtime/aws-smithy-client/src/timeout.rs index 85957eb11e..640e1c4562 100644 --- a/rust-runtime/aws-smithy-client/src/timeout.rs +++ b/rust-runtime/aws-smithy-client/src/timeout.rs @@ -25,7 +25,7 @@ struct RequestTimeoutError { } impl RequestTimeoutError { - pub fn new(kind: &'static str, duration: Duration) -> Self { + fn new(kind: &'static str, duration: Duration) -> Self { Self { kind, duration } } } @@ -59,7 +59,7 @@ pub(crate) struct ClientTimeoutParams { } impl ClientTimeoutParams { - pub fn new( + pub(crate) fn new( timeout_config: &OperationTimeoutConfig, async_sleep: Option>, ) -> Self { diff --git a/rust-runtime/aws-smithy-eventstream/src/buf.rs b/rust-runtime/aws-smithy-eventstream/src/buf.rs index 9e7c11ae72..31cbf40f18 100644 --- a/rust-runtime/aws-smithy-eventstream/src/buf.rs +++ b/rust-runtime/aws-smithy-eventstream/src/buf.rs @@ -3,5 +3,5 @@ * SPDX-License-Identifier: Apache-2.0 */ -pub mod count; -pub mod crc; +pub(crate) mod count; +pub(crate) mod crc; diff --git a/rust-runtime/aws-smithy-eventstream/src/buf/count.rs b/rust-runtime/aws-smithy-eventstream/src/buf/count.rs index 9fe6695473..ea9505d48d 100644 --- a/rust-runtime/aws-smithy-eventstream/src/buf/count.rs +++ b/rust-runtime/aws-smithy-eventstream/src/buf/count.rs @@ -8,7 +8,7 @@ use bytes::Buf; /// A [`Buf`] implementation that counts bytes read. -pub struct CountBuf<'a, B> +pub(crate) struct CountBuf<'a, B> where B: Buf, { @@ -21,12 +21,12 @@ where B: Buf, { /// Creates a new `CountBuf` by wrapping the given `buffer`. - pub fn new(buffer: &'a mut B) -> Self { + pub(crate) fn new(buffer: &'a mut B) -> Self { CountBuf { buffer, count: 0 } } /// Consumes the `CountBuf` and returns the number of bytes read. - pub fn into_count(self) -> usize { + pub(crate) fn into_count(self) -> usize { self.count } } diff --git a/rust-runtime/aws-smithy-eventstream/src/buf/crc.rs b/rust-runtime/aws-smithy-eventstream/src/buf/crc.rs index f9ec9f0ad5..f94f20f1ac 100644 --- a/rust-runtime/aws-smithy-eventstream/src/buf/crc.rs +++ b/rust-runtime/aws-smithy-eventstream/src/buf/crc.rs @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -//! Utilites for calculating CRC-32 while reading from a [`Buf`] or writing to a [`BufMut`]. +//! Utilities for calculating CRC-32 while reading from a [`Buf`] or writing to a [`BufMut`]. use bytes::buf::UninitSlice; use bytes::{Buf, BufMut}; @@ -11,7 +11,7 @@ use crc32fast::Hasher; /// Implementation of [`Buf`] that calculates a CRC-32 checksum of the data /// being read from an underlying `Buf` instance. -pub struct CrcBuf<'a, B> +pub(crate) struct CrcBuf<'a, B> where B: Buf, { @@ -24,7 +24,7 @@ where B: Buf, { /// Creates a new `CrcBuf` by wrapping the given `buffer`. - pub fn new(buffer: &'a mut B) -> Self { + pub(crate) fn new(buffer: &'a mut B) -> Self { CrcBuf { buffer, crc: Hasher::new(), @@ -32,7 +32,7 @@ where } /// Consumes the `CrcBuf` and returns the calculated checksum. - pub fn into_crc(self) -> u32 { + pub(crate) fn into_crc(self) -> u32 { self.crc.finalize() } } @@ -98,14 +98,14 @@ mod crc_buf_tests { /// Implementation of [`BufMut`] that calculates a CRC-32 checksum of the data /// being written to an underlying `Buf` instance, with a function to then write /// the calculated CRC-32 to the buffer. -pub struct CrcBufMut<'a> { +pub(crate) struct CrcBufMut<'a> { buffer: &'a mut dyn BufMut, crc: Hasher, } impl<'a> CrcBufMut<'a> { /// Creates a new `CrcBufMut` by wrapping the given `buffer`. - pub fn new(buffer: &'a mut dyn BufMut) -> Self { + pub(crate) fn new(buffer: &'a mut dyn BufMut) -> Self { CrcBufMut { buffer, crc: Hasher::new(), @@ -115,7 +115,7 @@ impl<'a> CrcBufMut<'a> { /// Puts the calculated CRC-32 to the buffer as a Big Endian 32-bit integer. /// This can be called multiple times, and each successive call will include /// the previously written checksum in its new checksum. - pub fn put_crc(&mut self) { + pub(crate) fn put_crc(&mut self) { self.put_u32(self.crc.clone().finalize()); } } diff --git a/rust-runtime/aws-smithy-eventstream/src/lib.rs b/rust-runtime/aws-smithy-eventstream/src/lib.rs index 594be5d3c9..0d060b914e 100644 --- a/rust-runtime/aws-smithy-eventstream/src/lib.rs +++ b/rust-runtime/aws-smithy-eventstream/src/lib.rs @@ -5,9 +5,9 @@ #![allow(clippy::derive_partial_eq_without_eq)] #![warn( - missing_debug_implementations, - /*missing_docs, - rustdoc::all,*/ + // missing_docs, + rustdoc::missing_crate_level_docs, + unreachable_pub, rust_2018_idioms )] diff --git a/rust-runtime/aws-smithy-http-auth/src/lib.rs b/rust-runtime/aws-smithy-http-auth/src/lib.rs index ada202143e..b245385253 100644 --- a/rust-runtime/aws-smithy-http-auth/src/lib.rs +++ b/rust-runtime/aws-smithy-http-auth/src/lib.rs @@ -4,7 +4,12 @@ */ #![allow(clippy::derive_partial_eq_without_eq)] -#![warn(missing_debug_implementations, missing_docs, rustdoc::all)] +#![warn( + missing_docs, + rustdoc::missing_crate_level_docs, + unreachable_pub, + rust_2018_idioms +)] //! Smithy HTTP Auth Types diff --git a/rust-runtime/aws-smithy-http-auth/src/location.rs b/rust-runtime/aws-smithy-http-auth/src/location.rs index 9fc0ced0e8..5b044cf904 100644 --- a/rust-runtime/aws-smithy-http-auth/src/location.rs +++ b/rust-runtime/aws-smithy-http-auth/src/location.rs @@ -54,7 +54,7 @@ impl AsRef for HttpAuthLocation { } impl std::fmt::Display for HttpAuthLocation { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(&self.as_str(), f) } } diff --git a/rust-runtime/aws-smithy-http-server-python/src/pytests/bytestream.rs b/rust-runtime/aws-smithy-http-server-python/src/pytests/bytestream.rs index a5d7ab0c9c..30cc997e76 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/pytests/bytestream.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/pytests/bytestream.rs @@ -145,7 +145,7 @@ async def handler(bytestream): } fn streaming_bytestream_from_vec(chunks: Vec<&'static str>) -> ByteStream { - let stream = stream::iter(chunks.into_iter().map(|v| Ok::<_, io::Error>(v))); + let stream = stream::iter(chunks.into_iter().map(Ok::<_, io::Error>)); let body = Body::wrap_stream(stream); ByteStream::new(SdkBody::from(body)) } diff --git a/rust-runtime/aws-smithy-http-server/src/protocols.rs b/rust-runtime/aws-smithy-http-server/src/protocols.rs index 2267c0384c..98d0223971 100644 --- a/rust-runtime/aws-smithy-http-server/src/protocols.rs +++ b/rust-runtime/aws-smithy-http-server/src/protocols.rs @@ -9,6 +9,7 @@ use http::HeaderMap; /// When there are no modeled inputs, /// a request body is empty and the content-type request header must not be set +#[allow(clippy::result_large_err)] pub fn content_type_header_empty_body_no_modeled_input(headers: &HeaderMap) -> Result<(), MissingContentTypeReason> { if headers.contains_key(http::header::CONTENT_TYPE) { let found_mime = parse_content_type(headers)?; @@ -21,6 +22,7 @@ pub fn content_type_header_empty_body_no_modeled_input(headers: &HeaderMap) -> R } } +#[allow(clippy::result_large_err)] fn parse_content_type(headers: &HeaderMap) -> Result { headers .get(http::header::CONTENT_TYPE) @@ -32,7 +34,7 @@ fn parse_content_type(headers: &HeaderMap) -> Result, diff --git a/rust-runtime/aws-smithy-http-tower/src/lib.rs b/rust-runtime/aws-smithy-http-tower/src/lib.rs index 92b60c2702..8a41796114 100644 --- a/rust-runtime/aws-smithy-http-tower/src/lib.rs +++ b/rust-runtime/aws-smithy-http-tower/src/lib.rs @@ -4,6 +4,12 @@ */ #![allow(clippy::derive_partial_eq_without_eq)] +#![warn( + // missing_docs, + // rustdoc::missing_crate_level_docs, + unreachable_pub, + rust_2018_idioms +)] pub mod dispatch; pub mod map_request; diff --git a/rust-runtime/aws-smithy-http/Cargo.toml b/rust-runtime/aws-smithy-http/Cargo.toml index 05e39ee18b..a54b17d2fb 100644 --- a/rust-runtime/aws-smithy-http/Cargo.toml +++ b/rust-runtime/aws-smithy-http/Cargo.toml @@ -28,7 +28,7 @@ pin-utils = "0.1.0" tracing = "0.1" # We are using hyper for our streaming body implementation, but this is an internal detail. -hyper = "0.14.12" +hyper = "0.14.25" # ByteStream internals futures-core = "0.3.14" @@ -38,7 +38,7 @@ tokio-util = { version = "0.7", optional = true } [dev-dependencies] async-stream = "0.3" futures-util = "0.3" -hyper = { version = "0.14.12", features = ["stream"] } +hyper = { version = "0.14.25", features = ["stream"] } pretty_assertions = "1.3" proptest = "1" tokio = { version = "1.8.4", features = [ diff --git a/rust-runtime/aws-smithy-http/src/body.rs b/rust-runtime/aws-smithy-http/src/body.rs index 8fea913b2b..32ad205ed2 100644 --- a/rust-runtime/aws-smithy-http/src/body.rs +++ b/rust-runtime/aws-smithy-http/src/body.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Types for representing the body of an HTTP request or response + use bytes::Bytes; use http::{HeaderMap, HeaderValue}; use http_body::{Body, SizeHint}; @@ -13,6 +15,7 @@ use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; +/// A generic, boxed error that's `Send` and `Sync` pub type Error = Box; pin_project! { @@ -44,6 +47,7 @@ impl Debug for SdkBody { } } +/// A boxed generic HTTP body that, when consumed, will result in [`Bytes`] or an [`Error`]. pub type BoxBody = http_body::combinators::BoxBody; pin_project! { @@ -109,6 +113,8 @@ impl SdkBody { } } + /// When an SdkBody is read, the inner data must be consumed. In order to do this, the SdkBody + /// is swapped with a "taken" body. This "taken" body cannot be read but aids in debugging. pub fn taken() -> Self { Self { inner: Inner::Taken, @@ -116,6 +122,7 @@ impl SdkBody { } } + /// Create an empty SdkBody for requests and responses that don't transfer any data in the body. pub fn empty() -> Self { Self { inner: Inner::Once { inner: None }, @@ -157,6 +164,8 @@ impl SdkBody { } } + /// Attempt to clone this SdkBody. This will fail if the inner data is not cloneable, such as when + /// it is a single-use stream that can't be recreated. pub fn try_clone(&self) -> Option { self.rebuild.as_ref().map(|rebuild| { let next = rebuild(); @@ -167,10 +176,14 @@ impl SdkBody { }) } + /// Return the length, in bytes, of this SdkBody. If this returns `None`, then the body does not + /// have a known length. pub fn content_length(&self) -> Option { http_body::Body::size_hint(self).exact() } + /// Given a function to modify an `SdkBody`, run that function against this `SdkBody` before + /// returning the result. pub fn map(self, f: impl Fn(SdkBody) -> SdkBody + Sync + Send + 'static) -> SdkBody { if self.rebuild.is_some() { SdkBody::retryable(move || f(self.try_clone().unwrap())) diff --git a/rust-runtime/aws-smithy-http/src/byte_stream.rs b/rust-runtime/aws-smithy-http/src/byte_stream.rs index e19ed3ac19..3b99c0a68d 100644 --- a/rust-runtime/aws-smithy-http/src/byte_stream.rs +++ b/rust-runtime/aws-smithy-http/src/byte_stream.rs @@ -262,12 +262,14 @@ pin_project! { } impl ByteStream { + /// Create a new `ByteStream` from an [`SdkBody`]. pub fn new(body: SdkBody) -> Self { Self { inner: Inner::new(body), } } + /// Create a new `ByteStream` from a static byte slice. pub fn from_static(bytes: &'static [u8]) -> Self { Self { inner: Inner::new(SdkBody::from(Bytes::from_static(bytes))), @@ -394,6 +396,8 @@ impl ByteStream { tokio_util::io::StreamReader::new(self) } + /// Given a function to modify an [`SdkBody`], run it on the `SdkBody` inside this `Bytestream`. + /// returning a new `Bytestream`. pub fn map(self, f: impl Fn(SdkBody) -> SdkBody + Send + Sync + 'static) -> ByteStream { ByteStream::new(self.into_inner().map(f)) } diff --git a/rust-runtime/aws-smithy-http/src/byte_stream/bytestream_util.rs b/rust-runtime/aws-smithy-http/src/byte_stream/bytestream_util.rs index 28937b2aac..3768a57509 100644 --- a/rust-runtime/aws-smithy-http/src/byte_stream/bytestream_util.rs +++ b/rust-runtime/aws-smithy-http/src/byte_stream/bytestream_util.rs @@ -58,7 +58,7 @@ impl PathBody { } } -/// Builder for creating [`ByteStreams`](crate::byte_stream::ByteStream) from a file/path, with full control over advanced options. +/// Builder for creating [`ByteStreams`](ByteStream) from a file/path, with full control over advanced options. /// /// Example usage: /// ```no_run @@ -84,8 +84,9 @@ impl PathBody { /// } /// # } /// ``` +#[allow(missing_debug_implementations)] pub struct FsBuilder { - file: Option, + file: Option, path: Option, length: Option, buffer_size: usize, @@ -99,6 +100,7 @@ impl Default for FsBuilder { } /// The length (in bytes) to read. Determines whether or not a short read counts as an error. +#[allow(missing_debug_implementations)] pub enum Length { /// Read this number of bytes exactly. Returns an error if the file is smaller than expected. Exact(u64), @@ -135,7 +137,7 @@ impl FsBuilder { /// /// NOTE: The resulting ByteStream (after calling [build](FsBuilder::build)) will not be a retryable ByteStream. /// For a ByteStream that can be retried in the case of upstream failures, use [`FsBuilder::path`](FsBuilder::path). - pub fn file(mut self, file: tokio::fs::File) -> Self { + pub fn file(mut self, file: File) -> Self { self.file = Some(file); self } @@ -167,7 +169,7 @@ impl FsBuilder { self } - /// Returns a [`ByteStream`](crate::byte_stream::ByteStream) from this builder. + /// Returns a [`ByteStream`](ByteStream) from this builder. pub async fn build(self) -> Result { if self.path.is_some() && self.file.is_some() { panic!("The 'file' and 'path' options on an FsBuilder are mutually exclusive but both were set. Please set only one") @@ -209,7 +211,7 @@ impl FsBuilder { } else if let Some(mut file) = self.file { // When starting from a `File`, we need to do our own seeking if offset != 0 { - let _s = file.seek(std::io::SeekFrom::Start(offset)).await?; + let _s = file.seek(io::SeekFrom::Start(offset)).await?; } let body = SdkBody::from_dyn(http_body::combinators::BoxBody::new( @@ -235,7 +237,7 @@ impl FsBuilder { enum State { Unloaded(PathBuf), Loading(Pin> + Send + Sync + 'static>>), - Loaded(tokio_util::io::ReaderStream>), + Loaded(ReaderStream>), } impl Body for PathBody { @@ -252,10 +254,10 @@ impl Body for PathBody { State::Unloaded(ref path_buf) => { let buf = path_buf.clone(); self.state = State::Loading(Box::pin(async move { - let mut file = tokio::fs::File::open(&buf).await?; + let mut file = File::open(&buf).await?; if offset != 0 { - let _s = file.seek(std::io::SeekFrom::Start(offset)).await?; + let _s = file.seek(io::SeekFrom::Start(offset)).await?; } Ok(file) @@ -574,7 +576,7 @@ mod test { for i in 0..chunks { let length = if i == chunks - 1 { // If we're on the last chunk, the length to read might be less than a whole chunk. - // We substract the size of all previous chunks from the total file size to get the + // We subtract the size of all previous chunks from the total file size to get the // size of the final chunk. file_size - (i * chunk_size) } else { diff --git a/rust-runtime/aws-smithy-http/src/byte_stream/error.rs b/rust-runtime/aws-smithy-http/src/byte_stream/error.rs index 8ea46acb3e..b0e29af6e6 100644 --- a/rust-runtime/aws-smithy-http/src/byte_stream/error.rs +++ b/rust-runtime/aws-smithy-http/src/byte_stream/error.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Errors related to bytestreams. + use std::error::Error as StdError; use std::fmt; use std::io::{Error as IoError, ErrorKind as IoErrorKind}; diff --git a/rust-runtime/aws-smithy-http/src/connection.rs b/rust-runtime/aws-smithy-http/src/connection.rs index 4649b0e8ee..eb81f63687 100644 --- a/rust-runtime/aws-smithy-http/src/connection.rs +++ b/rust-runtime/aws-smithy-http/src/connection.rs @@ -3,10 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Types related to connection monitoring and management. + use std::fmt::{Debug, Formatter}; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; +/// Metadata that tracks the state of an active connection. #[derive(Clone)] pub struct ConnectionMetadata { is_proxied: bool, @@ -14,6 +17,32 @@ pub struct ConnectionMetadata { poison_fn: Arc, } +impl ConnectionMetadata { + /// Poison this connection, ensuring that it won't be reused. + pub fn poison(&self) { + tracing::info!("smithy connection was poisoned"); + (self.poison_fn)() + } + + /// Create a new [`ConnectionMetadata`]. + pub fn new( + is_proxied: bool, + remote_addr: Option, + poison: impl Fn() + Send + Sync + 'static, + ) -> Self { + Self { + is_proxied, + remote_addr, + poison_fn: Arc::new(poison), + } + } + + /// Get the remote address for this connection, if one is set. + pub fn remote_addr(&self) -> Option { + self.remote_addr + } +} + impl Debug for ConnectionMetadata { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.debug_struct("SmithyConnection") @@ -25,17 +54,22 @@ impl Debug for ConnectionMetadata { type LoaderFn = dyn Fn() -> Option + Send + Sync; +/// State for a middleware that will monitor and manage connections. +#[allow(missing_debug_implementations)] #[derive(Clone, Default)] pub struct CaptureSmithyConnection { loader: Arc>>>, } impl CaptureSmithyConnection { + /// Create a new connection monitor. pub fn new() -> Self { Self { loader: Default::default(), } } + + /// Set the retriever that will capture the `hyper` connection. pub fn set_connection_retriever(&self, f: F) where F: Fn() -> Option + Send + Sync + 'static, @@ -43,6 +77,7 @@ impl CaptureSmithyConnection { *self.loader.lock().unwrap() = Some(Box::new(f)); } + /// Get the associated connection metadata. pub fn get(&self) -> Option { match self.loader.lock().unwrap().as_ref() { Some(loader) => loader(), @@ -54,31 +89,6 @@ impl CaptureSmithyConnection { } } -impl ConnectionMetadata { - pub fn poison(&self) { - tracing::info!("smithy connection was poisoned"); - (self.poison_fn)() - } -} - -impl ConnectionMetadata { - pub fn new( - is_proxied: bool, - remote_addr: Option, - poison: impl Fn() + Send + Sync + 'static, - ) -> Self { - Self { - is_proxied, - remote_addr, - poison_fn: Arc::new(poison), - } - } - - pub fn remote_addr(&self) -> Option { - self.remote_addr - } -} - #[cfg(test)] mod test { use crate::connection::{CaptureSmithyConnection, ConnectionMetadata}; diff --git a/rust-runtime/aws-smithy-http/src/endpoint.rs b/rust-runtime/aws-smithy-http/src/endpoint.rs index a0fcb0ef3a..e73cd05131 100644 --- a/rust-runtime/aws-smithy-http/src/endpoint.rs +++ b/rust-runtime/aws-smithy-http/src/endpoint.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Code for resolving an endpoint (URI) that a request should be sent to + use crate::endpoint::error::InvalidEndpointError; use crate::operation::error::BuildError; use http::uri::{Authority, Uri}; @@ -15,9 +17,13 @@ pub mod middleware; pub use error::ResolveEndpointError; +/// An endpoint-resolution-specific Result. Contains either an [`Endpoint`](aws_smithy_types::endpoint::Endpoint) or a [`ResolveEndpointError`]. pub type Result = std::result::Result; +/// Implementors of this trait can resolve an endpoint that will be applied to a request. pub trait ResolveEndpoint: Send + Sync { + /// Given some endpoint parameters, resolve an endpoint or return an error when resolution is + /// impossible. fn resolve_endpoint(&self, params: &Params) -> Result; } @@ -52,9 +58,12 @@ impl ResolveEndpoint for Endpoint { } } +/// A special type that adds support for services that have special URL-prefixing rules. #[derive(Clone, Debug, Eq, PartialEq)] pub struct EndpointPrefix(String); impl EndpointPrefix { + /// Create a new endpoint prefix from an `impl Into`. If the prefix argument is invalid, + /// a [`BuildError`] will be returned. pub fn new(prefix: impl Into) -> StdResult { let prefix = prefix.into(); match Authority::from_str(&prefix) { @@ -67,6 +76,7 @@ impl EndpointPrefix { } } + /// Get the `str` representation of this `EndpointPrefix`. pub fn as_str(&self) -> &str { &self.0 } diff --git a/rust-runtime/aws-smithy-http/src/endpoint/error.rs b/rust-runtime/aws-smithy-http/src/endpoint/error.rs index 47570fa4f8..bab0f93ac6 100644 --- a/rust-runtime/aws-smithy-http/src/endpoint/error.rs +++ b/rust-runtime/aws-smithy-http/src/endpoint/error.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Errors related to endpoint resolution and validation + use std::error::Error; use std::fmt; @@ -59,6 +61,8 @@ pub(super) enum InvalidEndpointErrorKind { }, } +/// An error that occurs when an endpoint is found to be invalid. This usually occurs due to an +/// incomplete URI. #[derive(Debug)] pub struct InvalidEndpointError { pub(super) kind: InvalidEndpointErrorKind, diff --git a/rust-runtime/aws-smithy-http/src/endpoint/middleware.rs b/rust-runtime/aws-smithy-http/src/endpoint/middleware.rs index 9f6c8e1a1e..1665df9bce 100644 --- a/rust-runtime/aws-smithy-http/src/endpoint/middleware.rs +++ b/rust-runtime/aws-smithy-http/src/endpoint/middleware.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! [`MapRequest`]-based middleware for resolving and applying a request's endpoint. + use crate::endpoint; use crate::endpoint::{apply_endpoint, EndpointPrefix, ResolveEndpointError}; use crate::middleware::MapRequest; @@ -19,6 +21,7 @@ use std::str::FromStr; #[derive(Default, Debug, Clone)] pub struct SmithyEndpointStage; impl SmithyEndpointStage { + /// Create a new `SmithyEndpointStage`. pub fn new() -> Self { Self::default() } diff --git a/rust-runtime/aws-smithy-http/src/event_stream.rs b/rust-runtime/aws-smithy-http/src/event_stream.rs index 8b09a5bb90..0b95bb2d1e 100644 --- a/rust-runtime/aws-smithy-http/src/event_stream.rs +++ b/rust-runtime/aws-smithy-http/src/event_stream.rs @@ -10,6 +10,7 @@ use std::error::Error as StdError; mod receiver; mod sender; +/// A generic, boxed error that's `Send`, `Sync`, and `'static`. pub type BoxError = Box; #[doc(inline)] diff --git a/rust-runtime/aws-smithy-http/src/event_stream/receiver.rs b/rust-runtime/aws-smithy-http/src/event_stream/receiver.rs index 04640fdc74..9d6a3bc398 100644 --- a/rust-runtime/aws-smithy-http/src/event_stream/receiver.rs +++ b/rust-runtime/aws-smithy-http/src/event_stream/receiver.rs @@ -109,6 +109,7 @@ enum ReceiverErrorKind { UnexpectedEndOfStream, } +/// An error that occurs within an event stream receiver. #[derive(Debug)] pub struct ReceiverError { kind: ReceiverErrorKind, 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 fb7af53714..a4faa3f236 100644 --- a/rust-runtime/aws-smithy-http/src/event_stream/sender.rs +++ b/rust-runtime/aws-smithy-http/src/event_stream/sender.rs @@ -49,6 +49,7 @@ where } } +/// An error that occurs within a message stream. #[derive(Debug)] pub struct MessageStreamError { kind: MessageStreamErrorKind, @@ -105,6 +106,7 @@ impl fmt::Display for MessageStreamError { /// /// This will yield an `Err(SdkError::ConstructionFailure)` if a message can't be /// marshalled into an Event Stream frame, (e.g., if the message payload was too large). +#[allow(missing_debug_implementations)] pub struct MessageStreamAdapter { marshaller: Box + Send + Sync>, error_marshaller: Box + Send + Sync>, @@ -117,6 +119,7 @@ pub struct MessageStreamAdapter { impl Unpin for MessageStreamAdapter {} impl MessageStreamAdapter { + /// Create a new `MessageStreamAdapter`. pub fn new( marshaller: impl MarshallMessage + Send + Sync + 'static, error_marshaller: impl MarshallMessage + Send + Sync + 'static, diff --git a/rust-runtime/aws-smithy-http/src/header.rs b/rust-runtime/aws-smithy-http/src/header.rs index 99695af4d5..b77edbdce0 100644 --- a/rust-runtime/aws-smithy-http/src/header.rs +++ b/rust-runtime/aws-smithy-http/src/header.rs @@ -15,6 +15,7 @@ use std::error::Error; use std::fmt; use std::str::FromStr; +/// An error was encountered while parsing a header #[derive(Debug)] pub struct ParseError { message: Cow<'static, str>, @@ -55,7 +56,7 @@ impl Error for ParseError { /// This is separate from `read_many` below because we need to invoke `DateTime::read` to take advantage /// of comma-aware parsing pub fn many_dates( - values: ValueIter, + values: ValueIter<'_, HeaderValue>, format: Format, ) -> Result, ParseError> { let mut out = vec![]; @@ -87,7 +88,10 @@ pub fn headers_for_prefix<'a>( .map(move |h| (&h.as_str()[key.len()..], h)) } -pub fn read_many_from_str(values: ValueIter) -> Result, ParseError> +/// Convert a `HeaderValue` into a `Vec` where `T: FromStr` +pub fn read_many_from_str( + values: ValueIter<'_, HeaderValue>, +) -> Result, ParseError> where T::Err: Error + Send + Sync + 'static, { @@ -98,7 +102,10 @@ where }) } -pub fn read_many_primitive(values: ValueIter) -> Result, ParseError> { +/// Convert a `HeaderValue` into a `Vec` where `T: Parse` +pub fn read_many_primitive( + values: ValueIter<'_, HeaderValue>, +) -> Result, ParseError> { read_many(values, |v: &str| { T::parse_smithy_primitive(v) .map_err(|err| ParseError::new("failed reading a list of primitives").with_source(err)) @@ -107,7 +114,7 @@ pub fn read_many_primitive(values: ValueIter) -> Result( - values: ValueIter, + values: ValueIter<'_, HeaderValue>, f: impl Fn(&str) -> Result, ) -> Result, ParseError> { let mut out = vec![]; @@ -125,7 +132,9 @@ fn read_many( /// Read exactly one or none from a headers iterator /// /// This function does not perform comma splitting like `read_many` -pub fn one_or_none(mut values: ValueIter) -> Result, ParseError> +pub fn one_or_none( + mut values: ValueIter<'_, HeaderValue>, +) -> Result, ParseError> where T::Err: Error + Send + Sync + 'static, { @@ -145,6 +154,7 @@ where } } +/// Given an HTTP request, set a request header if that header was not already set. pub fn set_request_header_if_absent( request: http::request::Builder, key: HeaderName, @@ -165,6 +175,7 @@ where } } +/// Given an HTTP response, set a response header if that header was not already set. pub fn set_response_header_if_absent( response: http::response::Builder, key: HeaderName, diff --git a/rust-runtime/aws-smithy-http/src/http.rs b/rust-runtime/aws-smithy-http/src/http.rs index 4c7bcbe93b..ad77e951c3 100644 --- a/rust-runtime/aws-smithy-http/src/http.rs +++ b/rust-runtime/aws-smithy-http/src/http.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Types for abstracting over HTTP requests and responses. + use http::{HeaderMap, HeaderValue}; /// Trait for accessing HTTP headers. diff --git a/rust-runtime/aws-smithy-http/src/label.rs b/rust-runtime/aws-smithy-http/src/label.rs index a4742aa0c6..e2f083a383 100644 --- a/rust-runtime/aws-smithy-http/src/label.rs +++ b/rust-runtime/aws-smithy-http/src/label.rs @@ -13,13 +13,17 @@ use percent_encoding::AsciiSet; const GREEDY: &AsciiSet = &BASE_SET.remove(b'/'); +/// The encoding strategy used when parsing an `httpLabel`. #[non_exhaustive] #[derive(Clone, Debug, Eq, PartialEq)] pub enum EncodingStrategy { + /// The default strategy when parsing an `httpLabel`. Only one path segment will be matched. Default, + /// When parsing an `httpLabel`, this strategy will attempt to parse as many path segments as possible. Greedy, } +/// Format a given `httpLabel` as a string according to an [`EncodingStrategy`] pub fn fmt_string>(t: T, strategy: EncodingStrategy) -> String { let uri_set = if strategy == EncodingStrategy::Greedy { GREEDY @@ -29,6 +33,7 @@ pub fn fmt_string>(t: T, strategy: EncodingStrategy) -> String { percent_encoding::utf8_percent_encode(t.as_ref(), uri_set).to_string() } +/// Format a given [`DateTime`] as a string according to an [`EncodingStrategy`] pub fn fmt_timestamp(t: &DateTime, format: Format) -> Result { Ok(fmt_string(t.fmt(format)?, EncodingStrategy::Default)) } diff --git a/rust-runtime/aws-smithy-http/src/lib.rs b/rust-runtime/aws-smithy-http/src/lib.rs index 77156efc2f..ad53e37f9c 100644 --- a/rust-runtime/aws-smithy-http/src/lib.rs +++ b/rust-runtime/aws-smithy-http/src/lib.rs @@ -3,6 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![warn( + missing_docs, + rustdoc::missing_crate_level_docs, + unreachable_pub, + rust_2018_idioms +)] + //! Core HTTP primitives for service clients generated by [smithy-rs](https://github.com/awslabs/smithy-rs) including: //! - HTTP Body implementation //! - Endpoint support diff --git a/rust-runtime/aws-smithy-http/src/middleware.rs b/rust-runtime/aws-smithy-http/src/middleware.rs index 091c7caa71..b77c65b935 100644 --- a/rust-runtime/aws-smithy-http/src/middleware.rs +++ b/rust-runtime/aws-smithy-http/src/middleware.rs @@ -30,12 +30,15 @@ type BoxError = Box; /// including signing & endpoint resolution. `AsyncMapRequest` is used for async credential /// retrieval (e.g., from AWS STS's AssumeRole operation). pub trait AsyncMapRequest { + /// The type returned when this [`AsyncMapRequest`] encounters an error. type Error: Into + 'static; + /// The type returned when [`AsyncMapRequest::apply`] is called. type Future: Future> + Send + 'static; /// Returns the name of this map request operation for inclusion in a tracing span. fn name(&self) -> &'static str; + /// Call this middleware, returning a future that resolves to a request or an error. fn apply(&self, request: operation::Request) -> Self::Future; } diff --git a/rust-runtime/aws-smithy-http/src/operation.rs b/rust-runtime/aws-smithy-http/src/operation.rs index 67dac362fb..a4d9657cfb 100644 --- a/rust-runtime/aws-smithy-http/src/operation.rs +++ b/rust-runtime/aws-smithy-http/src/operation.rs @@ -3,6 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Types for representing the interaction between a service an a client, referred to as an "operation" in smithy. +//! Clients "send" operations to services, which are composed of 1 or more HTTP requests. + use crate::body::SdkBody; use crate::property_bag::{PropertyBag, SharedPropertyBag}; use crate::retry::DefaultResponseRetryClassifier; @@ -49,8 +52,11 @@ impl Metadata { #[non_exhaustive] #[derive(Clone, Debug)] pub struct Parts { + /// The response deserializer that will convert the connector's response into an `operation::Response` pub response_handler: H, + /// The classifier that will determine if an HTTP response indicates that a request failed for a retryable reason. pub retry_classifier: R, + /// Metadata describing this operation and the service it relates to. pub metadata: Option, } diff --git a/rust-runtime/aws-smithy-http/src/operation/error.rs b/rust-runtime/aws-smithy-http/src/operation/error.rs index e6c8236ecb..5b2024396f 100644 --- a/rust-runtime/aws-smithy-http/src/operation/error.rs +++ b/rust-runtime/aws-smithy-http/src/operation/error.rs @@ -17,12 +17,14 @@ enum SerializationErrorKind { DateTimeFormatError { cause: DateTimeFormatError }, } +/// An error that occurs when serialization of an operation fails. #[derive(Debug)] pub struct SerializationError { kind: SerializationErrorKind, } impl SerializationError { + /// An error that occurs when serialization of an operation fails for an unknown reason. pub fn unknown_variant(union: &'static str) -> Self { Self { kind: SerializationErrorKind::CannotSerializeUnknownVariant { union }, diff --git a/rust-runtime/aws-smithy-http/src/property_bag.rs b/rust-runtime/aws-smithy-http/src/property_bag.rs index 57b2f07393..4964b7f09b 100644 --- a/rust-runtime/aws-smithy-http/src/property_bag.rs +++ b/rust-runtime/aws-smithy-http/src/property_bag.rs @@ -3,10 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -// This code is functionally equivalent to `Extensions` in the `http` crate. Examples -// have been updated to be more relevant for smithy use, the interface has been made public, -// and the doc comments have been updated to reflect how the property bag is used in the SDK. -// Additionally, optimizations around the HTTP use case have been removed in favor or simpler code. +//! A typemap used to store configuration for smithy operations. +//! +//! This code is functionally equivalent to `Extensions` in the `http` crate. Examples +//! have been updated to be more relevant for smithy use, the interface has been made public, +//! and the doc comments have been updated to reflect how the property bag is used in the SDK. +//! Additionally, optimizations around the HTTP use case have been removed in favor or simpler code. use std::any::{Any, TypeId}; use std::collections::HashMap; diff --git a/rust-runtime/aws-smithy-http/src/query.rs b/rust-runtime/aws-smithy-http/src/query.rs index a744259642..81ac8b344a 100644 --- a/rust-runtime/aws-smithy-http/src/query.rs +++ b/rust-runtime/aws-smithy-http/src/query.rs @@ -13,15 +13,17 @@ use aws_smithy_types::date_time::{DateTimeFormatError, Format}; use aws_smithy_types::DateTime; use percent_encoding::utf8_percent_encode; +/// Format a given string as a query string. pub fn fmt_string>(t: T) -> String { utf8_percent_encode(t.as_ref(), BASE_SET).to_string() } +/// Format a given [`DateTime`] as a query string. pub fn fmt_timestamp(t: &DateTime, format: Format) -> Result { Ok(fmt_string(t.fmt(format)?)) } -/// Simple abstraction to enable appending params to a string as query params +/// Simple abstraction to enable appending params to a string as query params. /// /// ```rust /// use aws_smithy_http::query::Writer; @@ -31,16 +33,19 @@ pub fn fmt_timestamp(t: &DateTime, format: Format) -> Result { out: &'a mut String, prefix: char, } impl<'a> Writer<'a> { + /// Create a new query string writer. pub fn new(out: &'a mut String) -> Self { Writer { out, prefix: '?' } } + /// Add a new key and value pair to this writer. pub fn push_kv(&mut self, k: &str, v: &str) { self.out.push(self.prefix); self.out.push_str(k); @@ -49,6 +54,7 @@ impl<'a> Writer<'a> { self.prefix = '&'; } + /// Add a new value (which is its own key) to this writer. pub fn push_v(&mut self, v: &str) { self.out.push(self.prefix); self.out.push_str(v); @@ -85,7 +91,7 @@ mod test { proptest! { #[test] fn test_encode_request(s: String) { - let _: Uri = format!("http://host.example.com/?{}", fmt_string(&s)).parse().expect("all strings should be encoded properly"); + let _: Uri = format!("http://host.example.com/?{}", fmt_string(s)).parse().expect("all strings should be encoded properly"); } } } diff --git a/rust-runtime/aws-smithy-http/src/query_writer.rs b/rust-runtime/aws-smithy-http/src/query_writer.rs index a7f9d7cfe1..d3251143f4 100644 --- a/rust-runtime/aws-smithy-http/src/query_writer.rs +++ b/rust-runtime/aws-smithy-http/src/query_writer.rs @@ -7,6 +7,7 @@ use crate::query::fmt_string as percent_encode_query; use http::Uri; /// Utility for updating the query string in a [`Uri`]. +#[allow(missing_debug_implementations)] pub struct QueryWriter { base_uri: Uri, new_path_and_query: String, diff --git a/rust-runtime/aws-smithy-http/src/response.rs b/rust-runtime/aws-smithy-http/src/response.rs index dbc2a694f6..9102fcbab4 100644 --- a/rust-runtime/aws-smithy-http/src/response.rs +++ b/rust-runtime/aws-smithy-http/src/response.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Types for response parsing. + use crate::operation; use bytes::Bytes; @@ -65,7 +67,10 @@ pub trait ParseHttpResponse { /// `ParseStrictResponse` enables operations that _never_ need to stream the body incrementally to /// have cleaner implementations. There is a blanket implementation pub trait ParseStrictResponse { + /// The type returned by this parser. type Output; + + /// Parse an [`http::Response`] into `Self::Output`. fn parse(&self, response: &http::Response) -> Self::Output; } @@ -91,8 +96,8 @@ mod test { #[test] fn supports_streaming_body() { - pub struct S3GetObject { - pub body: SdkBody, + struct S3GetObject { + _body: SdkBody, } struct S3GetObjectParser; @@ -103,7 +108,7 @@ mod test { fn parse_unloaded(&self, response: &mut operation::Response) -> Option { // For responses that pass on the body, use mem::take to leave behind an empty body let body = mem::replace(response.http_mut().body_mut(), SdkBody::taken()); - Some(S3GetObject { body }) + Some(S3GetObject { _body: body }) } fn parse_loaded(&self, _response: &http::Response) -> Self::Output { diff --git a/rust-runtime/aws-smithy-http/src/result.rs b/rust-runtime/aws-smithy-http/src/result.rs index a3fdfcc761..dd337a449c 100644 --- a/rust-runtime/aws-smithy-http/src/result.rs +++ b/rust-runtime/aws-smithy-http/src/result.rs @@ -3,13 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#![warn( - missing_debug_implementations, - missing_docs, - rustdoc::all, - unreachable_pub -)] - //! `Result` wrapper types for [success](SdkSuccess) and [failure](SdkError) responses. use crate::connection::ConnectionMetadata; diff --git a/rust-runtime/aws-smithy-http/src/retry.rs b/rust-runtime/aws-smithy-http/src/retry.rs index d7075b04e5..30c8654926 100644 --- a/rust-runtime/aws-smithy-http/src/retry.rs +++ b/rust-runtime/aws-smithy-http/src/retry.rs @@ -13,6 +13,7 @@ use aws_smithy_types::retry::{ErrorKind, ProvideErrorKind, RetryKind}; /// Classifies what kind of retry is needed for a given `response`. pub trait ClassifyRetry: Clone { + /// Run this classifier against a response to determine if it should be retried. fn classify_retry(&self, response: Result<&T, &E>) -> RetryKind; } diff --git a/rust-runtime/aws-smithy-json/src/deserialize.rs b/rust-runtime/aws-smithy-json/src/deserialize.rs index 64e30cb404..fd8e25cc26 100644 --- a/rust-runtime/aws-smithy-json/src/deserialize.rs +++ b/rust-runtime/aws-smithy-json/src/deserialize.rs @@ -25,7 +25,7 @@ pub use token::{EscapeError, EscapedStr, Offset, Token}; /// The parser *will* accept multiple valid JSON values. For example, `b"null true"` will /// yield `ValueNull` and `ValueTrue`. It is the responsibility of the caller to handle this for /// their use-case. -pub fn json_token_iter(input: &[u8]) -> JsonTokenIterator { +pub fn json_token_iter(input: &[u8]) -> JsonTokenIterator<'_> { JsonTokenIterator { input, index: 0, @@ -513,7 +513,10 @@ mod tests { use proptest::prelude::*; #[track_caller] - fn expect_token(expected: Option>, actual: Option>) { + fn expect_token( + expected: Option, Error>>, + actual: Option, Error>>, + ) { let (expected, actual) = ( expected.transpose().expect("err in expected"), actual.transpose().expect("err in actual"), @@ -670,7 +673,7 @@ mod tests { fn invalid_numbers() { macro_rules! unexpected_token { ($input:expr, $token:pat, $offset:expr, $msg:pat) => { - let tokens: Vec> = json_token_iter($input).collect(); + let tokens: Vec, Error>> = json_token_iter($input).collect(); assert_eq!(1, tokens.len()); expect_err!( ErrorKind::UnexpectedToken($token, $msg), @@ -681,7 +684,7 @@ mod tests { } let invalid_number = |input, offset| { - let tokens: Vec> = json_token_iter(input).collect(); + let tokens: Vec, Error>> = json_token_iter(input).collect(); assert_eq!(1, tokens.len()); expect_err!( ErrorKind::InvalidNumber, diff --git a/rust-runtime/aws-smithy-json/src/deserialize/token.rs b/rust-runtime/aws-smithy-json/src/deserialize/token.rs index f42fdafbda..fcce8365f2 100644 --- a/rust-runtime/aws-smithy-json/src/deserialize/token.rs +++ b/rust-runtime/aws-smithy-json/src/deserialize/token.rs @@ -135,7 +135,7 @@ expect_fn!( macro_rules! expect_value_or_null_fn { ($name:ident, $token:ident, $typ:ident, $doc:tt) => { #[doc=$doc] - pub fn $name(token: Option>) -> Result, Error> { + pub fn $name(token: Option, Error>>) -> Result, Error> { match token.transpose()? { Some(Token::ValueNull { .. }) => Ok(None), Some(Token::$token { value, .. }) => Ok(Some(value)), @@ -364,7 +364,7 @@ pub mod test { })) } - pub fn object_key(offset: usize, key: &str) -> Option> { + pub fn object_key(offset: usize, key: &str) -> Option, Error>> { Some(Ok(Token::ObjectKey { offset: Offset(offset), key: EscapedStr::new(key), @@ -391,7 +391,7 @@ pub mod test { })) } - pub fn value_string(offset: usize, string: &str) -> Option> { + pub fn value_string(offset: usize, string: &str) -> Option, Error>> { Some(Ok(Token::ValueString { offset: Offset(offset), value: EscapedStr::new(string), diff --git a/rust-runtime/aws-smithy-json/src/escape.rs b/rust-runtime/aws-smithy-json/src/escape.rs index 4643880a66..e09402abd9 100644 --- a/rust-runtime/aws-smithy-json/src/escape.rs +++ b/rust-runtime/aws-smithy-json/src/escape.rs @@ -53,7 +53,7 @@ impl From for EscapeError { } /// Escapes a string for embedding in a JSON string value. -pub fn escape_string(value: &str) -> Cow { +pub(crate) fn escape_string(value: &str) -> Cow<'_, str> { let bytes = value.as_bytes(); for (index, byte) in bytes.iter().enumerate() { match byte { @@ -94,7 +94,7 @@ fn escape_string_inner(start: &[u8], rest: &[u8]) -> String { /// Unescapes a JSON-escaped string. /// If there are no escape sequences, it directly returns the reference. -pub fn unescape_string(value: &str) -> Result, EscapeError> { +pub(crate) fn unescape_string(value: &str) -> Result, EscapeError> { let bytes = value.as_bytes(); for (index, byte) in bytes.iter().enumerate() { if *byte == b'\\' { diff --git a/rust-runtime/aws-smithy-json/src/lib.rs b/rust-runtime/aws-smithy-json/src/lib.rs index a4e6904924..08c324772e 100644 --- a/rust-runtime/aws-smithy-json/src/lib.rs +++ b/rust-runtime/aws-smithy-json/src/lib.rs @@ -4,6 +4,13 @@ */ #![allow(clippy::derive_partial_eq_without_eq)] +#![warn( + // missing_docs, + rustdoc::missing_crate_level_docs, + unreachable_pub, + // Enabling this requires fixing a macro but I don't understand how to do that. + // rust_2018_idioms +)] //! JSON Abstractions for Smithy diff --git a/rust-runtime/aws-smithy-json/src/serialize.rs b/rust-runtime/aws-smithy-json/src/serialize.rs index 128fb52914..744028efe4 100644 --- a/rust-runtime/aws-smithy-json/src/serialize.rs +++ b/rust-runtime/aws-smithy-json/src/serialize.rs @@ -134,7 +134,7 @@ impl<'a> JsonObjectWriter<'a> { } /// Starts a value with the given `key`. - pub fn key(&mut self, key: &str) -> JsonValueWriter { + pub fn key(&mut self, key: &str) -> JsonValueWriter<'_> { if self.started { self.json.push(','); } @@ -168,7 +168,7 @@ impl<'a> JsonArrayWriter<'a> { } /// Starts a new value in the array. - pub fn value(&mut self) -> JsonValueWriter { + pub fn value(&mut self) -> JsonValueWriter<'_> { self.comma_delimit(); JsonValueWriter::new(self.json) } diff --git a/rust-runtime/aws-smithy-protocol-test/src/lib.rs b/rust-runtime/aws-smithy-protocol-test/src/lib.rs index 735685ac53..da9c213d5d 100644 --- a/rust-runtime/aws-smithy-protocol-test/src/lib.rs +++ b/rust-runtime/aws-smithy-protocol-test/src/lib.rs @@ -3,6 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![warn( + // missing_docs, + // rustdoc::missing_crate_level_docs, + unreachable_pub, + rust_2018_idioms +)] + mod urlencoded; mod xml; @@ -156,7 +163,7 @@ pub fn forbid_query_params( request: &Request, forbid_params: &[&str], ) -> Result<(), ProtocolTestFailure> { - let actual_params: HashSet = extract_params(request.uri()) + let actual_params: HashSet> = extract_params(request.uri()) .iter() .map(|param| QueryParam::parse(param)) .collect(); @@ -488,11 +495,11 @@ mod tests { fn test_validate_json_body() { let expected = r#"{"abc": 5 }"#; let actual = r#" {"abc": 5 }"#; - validate_body(&actual, expected, MediaType::Json).expect("inputs matched as JSON"); + validate_body(actual, expected, MediaType::Json).expect("inputs matched as JSON"); let expected = r#"{"abc": 5 }"#; let actual = r#" {"abc": 6 }"#; - validate_body(&actual, expected, MediaType::Json).expect_err("bodies do not match"); + validate_body(actual, expected, MediaType::Json).expect_err("bodies do not match"); } #[test] @@ -501,22 +508,22 @@ mod tests { hello123 "#; let actual = "hello123"; - validate_body(&actual, expected, MediaType::Xml).expect("inputs match as XML"); + validate_body(actual, expected, MediaType::Xml).expect("inputs match as XML"); let expected = r#" hello123 "#; let actual = "hello124"; - validate_body(&actual, expected, MediaType::Xml).expect_err("inputs are different"); + validate_body(actual, expected, MediaType::Xml).expect_err("inputs are different"); } #[test] fn test_validate_non_json_body() { let expected = r#"asdf"#; let actual = r#"asdf "#; - validate_body(&actual, expected, MediaType::from("something/else")) + validate_body(actual, expected, MediaType::from("something/else")) .expect_err("bodies do not match"); - validate_body(&expected, expected, MediaType::from("something/else")) + validate_body(expected, expected, MediaType::from("something/else")) .expect("inputs matched exactly") } diff --git a/rust-runtime/aws-smithy-protocol-test/src/urlencoded.rs b/rust-runtime/aws-smithy-protocol-test/src/urlencoded.rs index fce91e4c9d..83c64e777b 100644 --- a/rust-runtime/aws-smithy-protocol-test/src/urlencoded.rs +++ b/rust-runtime/aws-smithy-protocol-test/src/urlencoded.rs @@ -40,7 +40,7 @@ fn rewrite_url_encoded_body(input: &str) -> String { entries.join("\n&") } -pub fn try_url_encoded_form_equivalent( +pub(crate) fn try_url_encoded_form_equivalent( actual: &str, expected: &str, ) -> Result<(), ProtocolTestFailure> { diff --git a/rust-runtime/aws-smithy-protocol-test/src/xml.rs b/rust-runtime/aws-smithy-protocol-test/src/xml.rs index 76a3ac9e11..c92882c5ee 100644 --- a/rust-runtime/aws-smithy-protocol-test/src/xml.rs +++ b/rust-runtime/aws-smithy-protocol-test/src/xml.rs @@ -11,7 +11,7 @@ use std::fmt::Write; /// /// This will normalize documents and attempts to determine if it is OK to sort members or not by /// using a heuristic to determine if the tag represents a list (which should not be reordered) -pub fn try_xml_equivalent(actual: &str, expected: &str) -> Result<(), ProtocolTestFailure> { +pub(crate) fn try_xml_equivalent(actual: &str, expected: &str) -> Result<(), ProtocolTestFailure> { let norm_1 = normalize_xml(actual).map_err(|e| ProtocolTestFailure::InvalidBodyFormat { expected: "actual document to be valid XML".to_string(), found: format!("{}\n{}", e, actual), @@ -34,20 +34,20 @@ pub fn try_xml_equivalent(actual: &str, expected: &str) -> Result<(), ProtocolTe /// /// This will normalize documents and attempts to determine if it is OK to sort members or not by /// using a heuristic to determine if the tag represents a list (which should not be reordered) -pub fn normalize_xml(s: &str) -> Result { +pub(crate) fn normalize_xml(s: &str) -> Result { let rotree = roxmltree::Document::parse(s)?; let root = rotree.root().first_child().unwrap(); Ok(unparse_tag(root, 1)) } -/// Unparse a "tag" (a subtree) of an XML document +/// Un-parse a "tag" (a subtree) of an XML document /// /// This function will first convert each of the tag's children into a normalized string /// then, assuming the node does not represent a list, it will simply lexicographically sort the fully /// rendered nodes themselves (avoiding the need to sort on keys then values then attributes, etc.). /// /// This is not a fast algorithm ;-), but the test data it's running on is not large. -fn unparse_tag(tag: Node, depth: usize) -> String { +fn unparse_tag(tag: Node<'_, '_>, depth: usize) -> String { let mut out = String::new(); out.push_str(&unparse_start_element(tag)); let mut child_nodes = tag @@ -78,7 +78,7 @@ fn unparse_tag(tag: Node, depth: usize) -> String { /// If the node is a start element, it will recursively convert all of its children /// If the node is text, it will return the text, stripped of whitespace /// If the node is neither, it is ignored -fn unparse_node(n: Node, depth: usize) -> Option { +fn unparse_node(n: Node<'_, '_>, depth: usize) -> Option { match n.node_type() { NodeType::Element => Some(unparse_tag(n, depth)), NodeType::Text => { @@ -96,7 +96,7 @@ fn unparse_node(n: Node, depth: usize) -> Option { /// Convert a node back into a string. Attributes are sorted by key, value, and namespace /// /// Produces output like: `` -fn unparse_start_element(n: Node) -> String { +fn unparse_start_element(n: Node<'_, '_>) -> String { let mut out = String::new(); out.push('<'); out.push_str(n.tag_name().name()); @@ -121,7 +121,7 @@ fn unparse_start_element(n: Node) -> String { out } -fn is_list(node: Node) -> bool { +fn is_list(node: Node<'_, '_>) -> bool { // a flat list looks like: // // example1 diff --git a/rust-runtime/aws-smithy-query/src/lib.rs b/rust-runtime/aws-smithy-query/src/lib.rs index 26e5ab50bf..9ce7799718 100644 --- a/rust-runtime/aws-smithy-query/src/lib.rs +++ b/rust-runtime/aws-smithy-query/src/lib.rs @@ -4,6 +4,12 @@ */ #![allow(clippy::derive_partial_eq_without_eq)] +#![warn( + // missing_docs, + rustdoc::missing_crate_level_docs, + unreachable_pub, + rust_2018_idioms +)] //! Abstractions for the Smithy AWS Query protocol @@ -27,7 +33,7 @@ impl<'a> QueryWriter<'a> { QueryWriter { output } } - pub fn prefix(&mut self, prefix: &'a str) -> QueryValueWriter { + pub fn prefix(&mut self, prefix: &'a str) -> QueryValueWriter<'_> { QueryValueWriter::new(self.output, Cow::Borrowed(prefix)) } @@ -64,7 +70,7 @@ impl<'a> QueryMapWriter<'a> { } } - pub fn entry(&mut self, key: &str) -> QueryValueWriter { + pub fn entry(&mut self, key: &str) -> QueryValueWriter<'_> { let entry = if self.flatten { "" } else { ".entry" }; write!( &mut self.output, @@ -117,7 +123,7 @@ impl<'a> QueryListWriter<'a> { } } - pub fn entry(&mut self) -> QueryValueWriter { + pub fn entry(&mut self) -> QueryValueWriter<'_> { let value_name = if self.flatten { format!("{}.{}", self.prefix, self.next_index) } else if self.member_override.is_some() { @@ -156,7 +162,7 @@ impl<'a> QueryValueWriter<'a> { } /// Starts a new prefix. - pub fn prefix(&mut self, prefix: &'a str) -> QueryValueWriter { + pub fn prefix(&mut self, prefix: &'a str) -> QueryValueWriter<'_> { QueryValueWriter::new( self.output, Cow::Owned(format!("{}.{}", self.prefix, prefix)), diff --git a/rust-runtime/aws-smithy-runtime-api/src/lib.rs b/rust-runtime/aws-smithy-runtime-api/src/lib.rs index ca1729c0da..7449e4232c 100644 --- a/rust-runtime/aws-smithy-runtime-api/src/lib.rs +++ b/rust-runtime/aws-smithy-runtime-api/src/lib.rs @@ -3,6 +3,15 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![warn( + // missing_docs, + rustdoc::missing_crate_level_docs, + unreachable_pub, + rust_2018_idioms +)] + +//! Basic types for the new smithy client orchestrator. + /// Smithy interceptors for smithy clients. /// /// Interceptors are lifecycle hooks that can read/modify requests and responses. diff --git a/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting.rs b/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting.rs index 7e0e9b1d45..fcb6085fbd 100644 --- a/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting.rs +++ b/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Code for rate-limiting smithy clients. + pub mod error; pub mod token; pub mod token_bucket; diff --git a/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting/error.rs b/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting/error.rs index f61f094ea1..b4f4d9821f 100644 --- a/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting/error.rs +++ b/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting/error.rs @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +//! Errors related to rate limiting + use std::fmt; /// Errors related to a token bucket. @@ -12,12 +14,14 @@ pub struct RateLimitingError { } impl RateLimitingError { + /// An error that occurs when no tokens are left in the bucket. pub fn no_tokens() -> Self { Self { kind: ErrorKind::NoTokens, } } + /// An error that occurs due to a bug in the code. Please report bugs you encounter. pub fn bug(s: impl ToString) -> Self { Self { kind: ErrorKind::Bug(s.to_string()), diff --git a/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting/token.rs b/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting/token.rs index dbab55419f..92cb565d8e 100644 --- a/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting/token.rs +++ b/rust-runtime/aws-smithy-runtime-api/src/retries/rate_limiting/token.rs @@ -46,9 +46,8 @@ impl Token for Standard { } fn forget(self) { - match self.permit { - Some(permit) => permit.forget(), - None => (), + if let Some(permit) = self.permit { + permit.forget() } } } diff --git a/rust-runtime/aws-smithy-runtime/src/lib.rs b/rust-runtime/aws-smithy-runtime/src/lib.rs index cb6d7d4d53..47887330db 100644 --- a/rust-runtime/aws-smithy-runtime/src/lib.rs +++ b/rust-runtime/aws-smithy-runtime/src/lib.rs @@ -3,6 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ +#![warn( + // missing_docs, + // rustdoc::missing_crate_level_docs, + unreachable_pub, + rust_2018_idioms +)] + pub mod config_bag; pub use crate::config_bag::ConfigBag; diff --git a/rust-runtime/aws-smithy-types-convert/src/lib.rs b/rust-runtime/aws-smithy-types-convert/src/lib.rs index c18ebec8e3..e44f5c1c53 100644 --- a/rust-runtime/aws-smithy-types-convert/src/lib.rs +++ b/rust-runtime/aws-smithy-types-convert/src/lib.rs @@ -9,9 +9,8 @@ #![warn( missing_docs, rustdoc::missing_crate_level_docs, - missing_debug_implementations, - rust_2018_idioms, - unreachable_pub + unreachable_pub, + rust_2018_idioms )] #[cfg(any(feature = "convert-time", feature = "convert-chrono"))] 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 a259371ce1..7253dec1ac 100644 --- a/rust-runtime/aws-smithy-types/src/date_time/format.rs +++ b/rust-runtime/aws-smithy-types/src/date_time/format.rs @@ -193,7 +193,7 @@ pub(crate) mod http_date { let mut out = String::with_capacity(32); fn push_digit(out: &mut String, digit: u8) { debug_assert!(digit < 10); - out.push((b'0' + digit as u8) as char); + out.push((b'0' + digit) as char); } out.push_str(weekday); diff --git a/rust-runtime/aws-smithy-types/src/lib.rs b/rust-runtime/aws-smithy-types/src/lib.rs index cc6c25e041..2634ff7f39 100644 --- a/rust-runtime/aws-smithy-types/src/lib.rs +++ b/rust-runtime/aws-smithy-types/src/lib.rs @@ -149,7 +149,7 @@ impl Number { match self { Number::PosInt(v) => v as f64, Number::NegInt(v) => v as f64, - Number::Float(v) => v as f64, + Number::Float(v) => v, } } diff --git a/rust-runtime/aws-smithy-xml/src/decode.rs b/rust-runtime/aws-smithy-xml/src/decode.rs index c567fbd9d9..522c5b12e3 100644 --- a/rust-runtime/aws-smithy-xml/src/decode.rs +++ b/rust-runtime/aws-smithy-xml/src/decode.rs @@ -170,7 +170,7 @@ impl<'a> StartEl<'a> { } /// Returns true of `el` at `depth` is a match for this `start_el` - fn end_el(&self, el: ElementEnd, depth: Depth) -> bool { + fn end_el(&self, el: ElementEnd<'_>, depth: Depth) -> bool { if depth != self.depth { return false; } @@ -428,7 +428,7 @@ fn next_start_element<'a, 'inp>( /// Returns the data element at the current position /// -/// If the current position is not a data element (and is instead a ) an error +/// If the current position is not a data element (and is instead a ``) an error /// will be returned pub fn try_data<'a, 'inp>( tokens: &'a mut impl Iterator, Depth), XmlDecodeError>>, diff --git a/rust-runtime/aws-smithy-xml/src/escape.rs b/rust-runtime/aws-smithy-xml/src/escape.rs index eed9f0ff10..35130f57a1 100644 --- a/rust-runtime/aws-smithy-xml/src/escape.rs +++ b/rust-runtime/aws-smithy-xml/src/escape.rs @@ -10,7 +10,7 @@ const ESCAPES: &[char] = &[ '&', '\'', '\"', '<', '>', '\u{00D}', '\u{00A}', '\u{0085}', '\u{2028}', ]; -pub fn escape(s: &str) -> Cow { +pub(crate) fn escape(s: &str) -> Cow<'_, str> { let mut remaining = s; if !s.contains(ESCAPES) { return Cow::Borrowed(s); diff --git a/rust-runtime/aws-smithy-xml/src/lib.rs b/rust-runtime/aws-smithy-xml/src/lib.rs index fcd4144700..a179c0993c 100644 --- a/rust-runtime/aws-smithy-xml/src/lib.rs +++ b/rust-runtime/aws-smithy-xml/src/lib.rs @@ -4,9 +4,16 @@ */ #![allow(clippy::derive_partial_eq_without_eq)] +#![warn( + // missing_docs, + rustdoc::missing_crate_level_docs, + unreachable_pub, + rust_2018_idioms +)] //! Abstractions for Smithy //! [XML Binding Traits](https://awslabs.github.io/smithy/1.0/spec/core/xml-traits.html) + pub mod decode; pub mod encode; mod escape; diff --git a/rust-runtime/aws-smithy-xml/src/unescape.rs b/rust-runtime/aws-smithy-xml/src/unescape.rs index 4195164946..5d9f71383f 100644 --- a/rust-runtime/aws-smithy-xml/src/unescape.rs +++ b/rust-runtime/aws-smithy-xml/src/unescape.rs @@ -15,7 +15,7 @@ use std::borrow::Cow; /// /// If no escape sequences are present, Cow<&'str> will be returned, avoiding the need /// to copy the String. -pub fn unescape(s: &str) -> Result, XmlDecodeError> { +pub(crate) fn unescape(s: &str) -> Result, XmlDecodeError> { // no &, no need to escape anything if !s.contains('&') { return Ok(Cow::Borrowed(s)); diff --git a/rust-runtime/aws-smithy-xml/tests/handwritten_parsers.rs b/rust-runtime/aws-smithy-xml/tests/handwritten_parsers.rs index 8db9e202c0..3d0ef718ab 100644 --- a/rust-runtime/aws-smithy-xml/tests/handwritten_parsers.rs +++ b/rust-runtime/aws-smithy-xml/tests/handwritten_parsers.rs @@ -44,7 +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)] + #[allow(clippy::disallowed_names)] let mut foo: Option = None; let mut bar: Option = None; foo = root.start_el().attr("foo").map(|attr| attr.to_string()); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6a423bf434..f701aa5354 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.63.0" +channel = "1.66.1" diff --git a/tools/ci-build/Dockerfile b/tools/ci-build/Dockerfile index 4e2f72e8dc..ba02b6ddfe 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.63.0 +ARG rust_stable_version=1.66.1 ARG rust_nightly_version=nightly-2022-11-16 FROM ${base_image} AS bare_base_image diff --git a/tools/ci-build/changelogger/tests/e2e_test.rs b/tools/ci-build/changelogger/tests/e2e_test.rs index 2431bad8a4..745e73ef47 100644 --- a/tools/ci-build/changelogger/tests/e2e_test.rs +++ b/tools/ci-build/changelogger/tests/e2e_test.rs @@ -485,7 +485,7 @@ author = "LukeMathWalker" ), ) .unwrap(); - fs::write(&release_manifest_path, "overwrite-me").unwrap(); + fs::write(release_manifest_path, "overwrite-me").unwrap(); subcommand_render(&RenderArgs { change_set: ChangeSet::SmithyRs, @@ -596,7 +596,7 @@ author = "rcoh" ), ) .unwrap(); - fs::write(&release_manifest_path, "overwrite-me").unwrap(); + fs::write(release_manifest_path, "overwrite-me").unwrap(); let result = subcommand_render(&RenderArgs { change_set: ChangeSet::SmithyRs, diff --git a/tools/ci-build/difftags/src/html.rs b/tools/ci-build/difftags/src/html.rs index e56c93a4e5..61c5594de5 100644 --- a/tools/ci-build/difftags/src/html.rs +++ b/tools/ci-build/difftags/src/html.rs @@ -18,7 +18,7 @@ pub fn write_html( ) -> Result<()> { for (page_num, page) in pages.iter().enumerate() { let file_path = file_path(output_dir, page_num); - let mut file = fs::File::create(&file_path)?; + let mut file = fs::File::create(file_path)?; write_header(&mut file, title.as_deref(), subtitle.as_deref(), pages)?; for (file_num, page_file) in page.files.iter().enumerate() { diff --git a/tools/ci-build/difftags/src/page.rs b/tools/ci-build/difftags/src/page.rs index 94ab30588c..76a1491f83 100644 --- a/tools/ci-build/difftags/src/page.rs +++ b/tools/ci-build/difftags/src/page.rs @@ -223,7 +223,7 @@ index 422b64415..9561909ed 100644 30 "#; let mut patch = PatchSet::new(); - patch.parse(&diff_str).unwrap(); + patch.parse(diff_str).unwrap(); let hunk = &patch.files()[0].hunks()[0]; let section: Section = hunk.into(); @@ -292,7 +292,7 @@ index 422b64415..9561909ed 100644 36 "#; let mut patch = PatchSet::new(); - patch.parse(&diff_str).unwrap(); + patch.parse(diff_str).unwrap(); let hunk = &patch.files()[0].hunks()[0]; let section: Section = hunk.into(); diff --git a/tools/ci-build/publisher/src/publish.rs b/tools/ci-build/publisher/src/publish.rs index 7d95a838eb..1a835a7a49 100644 --- a/tools/ci-build/publisher/src/publish.rs +++ b/tools/ci-build/publisher/src/publish.rs @@ -40,7 +40,7 @@ pub async fn publish(handle: &PackageHandle, crate_path: &Path) -> anyhow::Resul 5, Duration::from_secs(60), || async { - cargo::Publish::new(handle.clone(), &crate_path) + cargo::Publish::new(handle.clone(), crate_path) .spawn() .await?; Result::<_, BoxError>::Ok(()) diff --git a/tools/ci-build/publisher/src/sort.rs b/tools/ci-build/publisher/src/sort.rs index a6da808a4e..5c1d273294 100644 --- a/tools/ci-build/publisher/src/sort.rs +++ b/tools/ci-build/publisher/src/sort.rs @@ -19,11 +19,7 @@ pub fn dependency_order(packages: Vec) -> Result> { let mut visited = BTreeSet::new(); let mut to_visit: Vec<&Package> = packages.iter().map(|e| e.1).collect(); - to_visit.sort_by(|a, b| { - (*a).local_dependencies - .len() - .cmp(&(*b).local_dependencies.len()) - }); + to_visit.sort_by(|a, b| a.local_dependencies.len().cmp(&b.local_dependencies.len())); // Depth-first search topological sort while let Some(package) = to_visit.iter().find(|e| !visited.contains(&e.handle)) { diff --git a/tools/ci-build/publisher/src/subcommand/generate_version_manifest.rs b/tools/ci-build/publisher/src/subcommand/generate_version_manifest.rs index 20751b856e..e06c79c6fa 100644 --- a/tools/ci-build/publisher/src/subcommand/generate_version_manifest.rs +++ b/tools/ci-build/publisher/src/subcommand/generate_version_manifest.rs @@ -45,7 +45,7 @@ pub async fn subcommand_generate_version_manifest( ) -> Result<()> { verify_crate_hasher_available()?; - let repo_root = find_git_repository_root("smithy-rs", &std::env::current_dir()?)?; + let repo_root = find_git_repository_root("smithy-rs", std::env::current_dir()?)?; let smithy_rs_revision = GitCLI::new(&repo_root)? .get_head_revision() .context("get smithy-rs revision")?; diff --git a/tools/ci-build/publisher/src/subcommand/hydrate_readme.rs b/tools/ci-build/publisher/src/subcommand/hydrate_readme.rs index bf63116406..683a570f40 100644 --- a/tools/ci-build/publisher/src/subcommand/hydrate_readme.rs +++ b/tools/ci-build/publisher/src/subcommand/hydrate_readme.rs @@ -38,7 +38,7 @@ pub fn subcommand_hydrate_readme( ) -> Result<()> { let versions_manifest = VersionsManifest::from_file(versions_manifest) .with_context(|| format!("Failed to read versions manifest at {versions_manifest:?}"))?; - let template = fs::read_to_string(&input) + let template = fs::read_to_string(input) .with_context(|| format!("Failed to read README template file at {input:?}"))?; let mut context = json!({ "msrv": msrv }); diff --git a/tools/ci-build/sdk-lints/src/anchor.rs b/tools/ci-build/sdk-lints/src/anchor.rs index 6de8383872..34ebe53e3c 100644 --- a/tools/ci-build/sdk-lints/src/anchor.rs +++ b/tools/ci-build/sdk-lints/src/anchor.rs @@ -22,7 +22,7 @@ pub fn replace_anchor( ) -> anyhow::Result { let anchor_start = anchors.0.as_ref(); let anchor_end = anchors.1.as_ref(); - let start = haystack.find(&anchor_start); + let start = haystack.find(anchor_start); if start.is_none() { if haystack.contains(anchor_end) { bail!("found end anchor but no start anchor"); @@ -33,8 +33,8 @@ pub fn replace_anchor( haystack.push_str(anchor_end); return Ok(true); } - let start = start.unwrap_or_else(|| haystack.find(&anchor_start).expect("must be present")); - let end = match haystack[start..].find(&anchor_end) { + let start = start.unwrap_or_else(|| haystack.find(anchor_start).expect("must be present")); + let end = match haystack[start..].find(anchor_end) { Some(end) => end + start, None => bail!("expected matching end anchor {}", anchor_end), }; @@ -77,9 +77,6 @@ mod test { ); // no replacement should return false - assert_eq!( - replace_anchor(&mut text, &anchors("foo"), "goodbye!").unwrap(), - false - ) + assert!(!replace_anchor(&mut text, &anchors("foo"), "goodbye!").unwrap(),) } } diff --git a/tools/ci-build/sdk-versioner/src/main.rs b/tools/ci-build/sdk-versioner/src/main.rs index 9ba312776a..4a74adcc2a 100644 --- a/tools/ci-build/sdk-versioner/src/main.rs +++ b/tools/ci-build/sdk-versioner/src/main.rs @@ -84,7 +84,7 @@ fn main() -> Result<()> { }, Args::UseVersionDependencies { versions_toml, .. } => DependencyContext { sdk_path: None, - versions_manifest: Some(VersionsManifest::from_file(&versions_toml)?), + versions_manifest: Some(VersionsManifest::from_file(versions_toml)?), }, Args::UsePathAndVersionDependencies { sdk_path, @@ -92,7 +92,7 @@ fn main() -> Result<()> { .. } => DependencyContext { sdk_path: Some(sdk_path), - versions_manifest: Some(VersionsManifest::from_file(&versions_toml)?), + versions_manifest: Some(VersionsManifest::from_file(versions_toml)?), }, }; @@ -134,7 +134,7 @@ fn update_manifest( } if changed { - fs::write(manifest_path, &toml::to_vec(&metadata)?)?; + fs::write(manifest_path, toml::to_vec(&metadata)?)?; } Ok(()) diff --git a/tools/ci-build/smithy-rs-tool-common/src/changelog.rs b/tools/ci-build/smithy-rs-tool-common/src/changelog.rs index e6524dc9be..4944c7aa4c 100644 --- a/tools/ci-build/smithy-rs-tool-common/src/changelog.rs +++ b/tools/ci-build/smithy-rs-tool-common/src/changelog.rs @@ -389,7 +389,7 @@ mod tests { let res = changelog.validate(); assert!(res.is_ok()); if let Err(e) = res { - assert!(false, "some error has been produced {e:?}"); + panic!("some error has been produced {e:?}"); } assert_eq!(changelog.smithy_rs[1].meta.target, Some(SdkAffected::All)); } diff --git a/tools/ci-cdk/canary-lambda/src/latest/paginator_canary.rs b/tools/ci-cdk/canary-lambda/src/latest/paginator_canary.rs index 291f717986..43dbe7b0f9 100644 --- a/tools/ci-cdk/canary-lambda/src/latest/paginator_canary.rs +++ b/tools/ci-cdk/canary-lambda/src/latest/paginator_canary.rs @@ -30,7 +30,7 @@ pub async fn paginator_canary(client: ec2::Client, page_size: usize) -> anyhow:: let mut num_pages = 0; while let Some(page) = history.try_next().await? { let items_in_page = page.spot_price_history.unwrap_or_default().len(); - if items_in_page > page_size as usize { + if items_in_page > page_size { bail!( "failed to retrieve results of correct page size (expected {}, got {})", page_size, diff --git a/tools/ci-cdk/canary-runner/src/build_bundle.rs b/tools/ci-cdk/canary-runner/src/build_bundle.rs index 0d214f4d89..5309c4fdfb 100644 --- a/tools/ci-cdk/canary-runner/src/build_bundle.rs +++ b/tools/ci-cdk/canary-runner/src/build_bundle.rs @@ -259,7 +259,7 @@ pub async fn build_bundle(opt: BuildBundleArgs) -> Result> { path.join("release") }; let bin_path = target_path.join("bootstrap"); - let bundle_path = target_path.join(&name_bundle( + let bundle_path = target_path.join(name_bundle( &bin_path, opt.rust_version.as_deref(), opt.sdk_release_tag.as_ref(), @@ -329,7 +329,6 @@ mod tests { "--sdk-release-tag", "release-2022-07-26" ]) - .ok() .expect("valid args") ); assert_eq!( @@ -349,7 +348,6 @@ mod tests { "--canary-path", "some-canary-path" ]) - .ok() .expect("valid args") ); assert_eq!( @@ -369,7 +367,6 @@ mod tests { "--musl", "--manifest-only" ]) - .ok() .expect("valid args") ); assert_eq!( @@ -391,7 +388,6 @@ mod tests { "--canary-path", "some-canary-path" ]) - .ok() .expect("valid args") ); } diff --git a/tools/echo-server/Cargo.lock b/tools/echo-server/Cargo.lock index 2efeb1952f..07ba693807 100644 --- a/tools/echo-server/Cargo.lock +++ b/tools/echo-server/Cargo.lock @@ -235,9 +235,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.20" +version = "0.14.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" +checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" dependencies = [ "bytes", "futures-channel", diff --git a/tools/echo-server/Cargo.toml b/tools/echo-server/Cargo.toml index f11225b64c..df50f243be 100644 --- a/tools/echo-server/Cargo.toml +++ b/tools/echo-server/Cargo.toml @@ -11,4 +11,4 @@ tokio = { version = "1.20.1", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } tower = { version = "0.4", features = ["util", "filter"] } -hyper = { version = "0.14.12", features = ["full"] } +hyper = { version = "0.14.25", features = ["full"] }