diff --git a/.github/workflows/lint-rust.yml b/.github/workflows/lint-rust.yml index f5c0bec4477..28d9a001250 100644 --- a/.github/workflows/lint-rust.yml +++ b/.github/workflows/lint-rust.yml @@ -27,7 +27,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable if: steps.changed-files.outputs.any_changed == 'true' with: - toolchain: "1.80.1" + toolchain: "1.81.0" components: clippy, rustfmt - name: Set Environment if: steps.changed-files.outputs.any_changed == 'true' diff --git a/rustv1/README.md b/rustv1/README.md index 769e8786cda..75dc3b35841 100644 --- a/rustv1/README.md +++ b/rustv1/README.md @@ -96,6 +96,10 @@ hosted on [Amazon Elastic Container Registry (ECR)](https://docs.aws.amazon.com/ with all Rust examples with dependencies pre-resolved, allowing you to explore these examples in an isolated environment. +## Updating Rust Version + +If a rust version releases (most likely) a clippy or has some other breaking change, the Weathertop dashboard will go red. The easiest way to handle this is to run `./tools/set_rust_version.py [rust_version]` (using a venv with the appropriate requirements), creating a commit with those updates, and then running `cargo clippy --fix` in the appropriate folder before making a second commit with those fixes. Line numbers will certainly change, so don't forget to run WRITEME - `./.tools/readmes/.venv/bin/python ./.tools/readmes/writeme.py --languages Rust:1`. + ## Contributing When adding or modifying Rust code examples, follow common Rust best practices. diff --git a/rustv1/cross_service/rust-toolchain.toml b/rustv1/cross_service/rust-toolchain.toml index 947b162e317..9c72c7b1031 100644 --- a/rustv1/cross_service/rust-toolchain.toml +++ b/rustv1/cross_service/rust-toolchain.toml @@ -1,3 +1,3 @@ # This should be kept in sync with https://github.com/awslabs/aws-sdk-rust#supported-rust-versions-msrv [toolchain] -channel = "1.80.1" +channel = "1.81.0" diff --git a/rustv1/examples/aurora/src/aurora_scenario/tests.rs b/rustv1/examples/aurora/src/aurora_scenario/tests.rs index 70f8a5e5051..7c41b81bf45 100644 --- a/rustv1/examples/aurora/src/aurora_scenario/tests.rs +++ b/rustv1/examples/aurora/src/aurora_scenario/tests.rs @@ -952,7 +952,7 @@ async fn test_scenario_clean_up_errors() { assert!(clean_up.is_err()); let errs = clean_up.unwrap_err(); assert_eq!(errs.len(), 2); - assert_matches!(errs.get(0), Some(ScenarioError {message, context: _}) if message == "Failed to check instance state during deletion"); + assert_matches!(errs.first(), Some(ScenarioError {message, context: _}) if message == "Failed to check instance state during deletion"); assert_matches!(errs.get(1), Some(ScenarioError {message, context: _}) if message == "Failed to check cluster state during deletion"); }); diff --git a/rustv1/examples/iam/README.md b/rustv1/examples/iam/README.md index 5bb01e435af..7665260a68e 100644 --- a/rustv1/examples/iam/README.md +++ b/rustv1/examples/iam/README.md @@ -45,30 +45,30 @@ Code examples that show you how to perform the essential operations within a ser Code excerpts that show you how to call individual service functions. -- [AttachRolePolicy](src/iam-service-lib.rs#L221) -- [AttachUserPolicy](src/iam-service-lib.rs#L236) -- [CreateAccessKey](src/iam-service-lib.rs#L270) +- [AttachRolePolicy](src/iam-service-lib.rs#L190) +- [AttachUserPolicy](src/iam-service-lib.rs#L205) +- [CreateAccessKey](src/iam-service-lib.rs#L239) - [CreatePolicy](src/iam-service-lib.rs#L18) -- [CreateRole](src/iam-service-lib.rs#L65) -- [CreateServiceLinkedRole](src/iam-service-lib.rs#L417) -- [CreateUser](src/iam-service-lib.rs#L87) -- [DeleteAccessKey](src/iam-service-lib.rs#L294) -- [DeletePolicy](src/iam-service-lib.rs#L338) -- [DeleteRole](src/iam-service-lib.rs#L160) -- [DeleteServiceLinkedRole](src/iam-service-lib.rs#L176) -- [DeleteUser](src/iam-service-lib.rs#L191) -- [DeleteUserPolicy](src/iam-service-lib.rs#L349) -- [DetachRolePolicy](src/iam-service-lib.rs#L321) -- [DetachUserPolicy](src/iam-service-lib.rs#L253) -- [GetAccountPasswordPolicy](src/iam-service-lib.rs#L436) -- [GetRole](src/iam-service-lib.rs#L113) -- [ListAttachedRolePolicies](src/iam-service-lib.rs#L446) -- [ListGroups](src/iam-service-lib.rs#L398) -- [ListPolicies](src/iam-service-lib.rs#L366) -- [ListRolePolicies](src/iam-service-lib.rs#L467) -- [ListRoles](src/iam-service-lib.rs#L95) -- [ListSAMLProviders](src/iam-service-lib.rs#L486) -- [ListUsers](src/iam-service-lib.rs#L123) +- [CreateRole](src/iam-service-lib.rs#L34) +- [CreateServiceLinkedRole](src/iam-service-lib.rs#L386) +- [CreateUser](src/iam-service-lib.rs#L56) +- [DeleteAccessKey](src/iam-service-lib.rs#L263) +- [DeletePolicy](src/iam-service-lib.rs#L307) +- [DeleteRole](src/iam-service-lib.rs#L129) +- [DeleteServiceLinkedRole](src/iam-service-lib.rs#L145) +- [DeleteUser](src/iam-service-lib.rs#L160) +- [DeleteUserPolicy](src/iam-service-lib.rs#L318) +- [DetachRolePolicy](src/iam-service-lib.rs#L290) +- [DetachUserPolicy](src/iam-service-lib.rs#L222) +- [GetAccountPasswordPolicy](src/iam-service-lib.rs#L405) +- [GetRole](src/iam-service-lib.rs#L82) +- [ListAttachedRolePolicies](src/iam-service-lib.rs#L415) +- [ListGroups](src/iam-service-lib.rs#L367) +- [ListPolicies](src/iam-service-lib.rs#L335) +- [ListRolePolicies](src/iam-service-lib.rs#L436) +- [ListRoles](src/iam-service-lib.rs#L64) +- [ListSAMLProviders](src/iam-service-lib.rs#L455) +- [ListUsers](src/iam-service-lib.rs#L92) diff --git a/rustv1/examples/iam/src/iam-service-lib.rs b/rustv1/examples/iam/src/iam-service-lib.rs index 503de38d66d..b3bfb6cc5c3 100644 --- a/rustv1/examples/iam/src/iam-service-lib.rs +++ b/rustv1/examples/iam/src/iam-service-lib.rs @@ -31,37 +31,6 @@ pub async fn create_policy( } // snippet-end:[rust.example_code.iam.service.create_policy] -#[cfg(test)] -mod test_create_policy { - use crate::create_policy; - use http::StatusCode; - use sdk_examples_test_utils::single_shot_client; - - #[tokio::test] - async fn test_create_policy_success() { - let client = single_shot_client!( - sdk: aws_sdk_iam, - status: StatusCode::OK, - response: include_str!("../testing/test_create_policy_response_success.xml") - ); - - let response = create_policy(&client, "{}", "test_role").await; - assert!(response.is_ok()); - } - - #[tokio::test] - async fn test_create_policy_failed() { - let client = single_shot_client!( - sdk: aws_sdk_iam, - status: StatusCode::BAD_REQUEST, - response: include_str!("../testing/test_create_policy_response_malformed.xml") - ); - - let response = create_policy(&client, "{}", "test_role").await; - assert!(response.is_err()); - } -} - // snippet-start:[rust.example_code.iam.service.create_role] pub async fn create_role( client: &iamClient, @@ -493,4 +462,37 @@ pub async fn list_saml_providers( } // snippet-end:[rust.example_code.iam.service.list_saml_providers] +// snippet-start:[rust.example_code.iam.service.create_policy.test] +#[cfg(test)] +mod test_create_policy { + use crate::create_policy; + use http::StatusCode; + use sdk_examples_test_utils::single_shot_client; + + #[tokio::test] + async fn test_create_policy_success() { + let client = single_shot_client!( + sdk: aws_sdk_iam, + status: StatusCode::OK, + response: include_str!("../testing/test_create_policy_response_success.xml") + ); + + let response = create_policy(&client, "{}", "test_role").await; + assert!(response.is_ok()); + } + + #[tokio::test] + async fn test_create_policy_failed() { + let client = single_shot_client!( + sdk: aws_sdk_iam, + status: StatusCode::BAD_REQUEST, + response: include_str!("../testing/test_create_policy_response_malformed.xml") + ); + + let response = create_policy(&client, "{}", "test_role").await; + assert!(response.is_err()); + } +} +// snippet-end:[rust.example_code.iam.service.create_policy.test] + // snippet-end:[rust.example_code.iam.scenario_getting_started.lib] diff --git a/rustv1/examples/rust-toolchain.toml b/rustv1/examples/rust-toolchain.toml index 947b162e317..9c72c7b1031 100644 --- a/rustv1/examples/rust-toolchain.toml +++ b/rustv1/examples/rust-toolchain.toml @@ -1,3 +1,3 @@ # This should be kept in sync with https://github.com/awslabs/aws-sdk-rust#supported-rust-versions-msrv [toolchain] -channel = "1.80.1" +channel = "1.81.0"