Skip to content

Commit

Permalink
Upgrade MSRV to 1.78.0 (#3800)
Browse files Browse the repository at this point in the history
## Motivation and Context
Upgrades MSRV to 1.78.0 since the [latest
Rust](https://www.rust-lang.org/) at the time of writing is 1.80.1 (we
try keeping [two releases
behind](https://github.com/awslabs/aws-sdk-rust?tab=readme-ov-file#supported-rust-versions-msrv)).

## Description
In Rust 1.78.0, `clippy` enforces stricter checks in two areas:
- `dead_code`
It seems to be able to uncover more unused code patterns, especially
when different combinations of cargo features are enabled
- `empty_docs`
Prior to 1.78.0, the codegen used to render the following empty docs
`///`, regardless whether the codegen is for the server or for the
client. This is now flagged as `empty_docs` by `clippy`:
```
///
pub(crate) mod XXX {
    ...
}
```

Other than bumping MSRV to 1.78.0, the remaining code changes address
issues related to the fixes mentioned above.

**EDIT:**
`cargo-semver-checks` required an upgrade due to incompatibility issues
following the MSRV upgrade ([example
error](https://github.com/smithy-lang/smithy-rs/actions/runs/10534205294/job/29261105195#step:4:2068)).
Specifically, after updating the MSRV to 1.78.0, the rustdoc version was
upgraded to v28. However, the version of `cargo-semver-checks` we were
using (0.24.1) only supported rustdoc [up to
v27](https://github.com/obi1kenobi/cargo-semver-checks/blob/4bce03d4a6a32cf651b9eccddb40e3418dc2c154/Cargo.toml#L18).

To resolve this, we have updated `cargo-semver-checks` to the first
version that supports rustdoc
[v28](https://github.com/obi1kenobi/cargo-semver-checks/blob/94a491f0854f0bdbccbb301099db119201bff181/Cargo.toml#L18).

## Testing
Existing tests in CI

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] For changes to the smithy-rs codegen or runtime crates, I have
created a changelog entry Markdown file in the `.changelog` directory,
specifying "client," "server," or both in the `applies_to` key.
- [x] For changes to the AWS SDK, generated SDK code, or SDK runtime
crates, I have created a changelog entry Markdown file in the
`.changelog` directory, specifying "aws-sdk-rust" in the `applies_to`
key.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
ysaito1001 authored Aug 27, 2024
1 parent d558415 commit 740edcc
Show file tree
Hide file tree
Showing 30 changed files with 87 additions and 156 deletions.
14 changes: 14 additions & 0 deletions .changelog/1724459075.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
applies_to:
- client
- server
- aws-sdk-rust
authors:
- ysaito1001
references:
- smithy-rs#3800
breaking: true
new_feature: false
bug_fix: false
---
Upgrade MSRV to Rust 1.78.0.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ on:
required: false

env:
rust_version: 1.76.0
rust_version: 1.78.0
rust_toolchain_components: clippy,rustfmt
ENCRYPTED_DOCKER_PASSWORD: ${{ secrets.ENCRYPTED_DOCKER_PASSWORD }}
DOCKER_LOGIN_TOKEN_PASSPHRASE: ${{ secrets.DOCKER_LOGIN_TOKEN_PASSPHRASE }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/claim-crate-names.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: true

env:
rust_version: 1.76.0
rust_version: 1.78.0

name: Claim unpublished crate names on crates.io
run-name: ${{ github.workflow }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
name: Update GitHub Pages

env:
rust_version: 1.76.0
rust_version: 1.78.0

# Allow only one doc pages build to run at a time for the entire smithy-rs repo
concurrency:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: true

env:
rust_version: 1.76.0
rust_version: 1.78.0

name: Release smithy-rs
on:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-sdk-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.76.0
toolchain: 1.78.0
- name: Delete old SDK
run: |
- name: Generate a fresh SDK
Expand Down
12 changes: 7 additions & 5 deletions aws/rust-runtime/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-credential-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aws-credential-types"
version = "1.2.0"
version = "1.2.1"
authors = ["AWS Rust SDK Team <[email protected]>"]
description = "Types for AWS SDK credentials."
edition = "2021"
Expand Down
31 changes: 1 addition & 30 deletions aws/rust-runtime/aws-credential-types/src/credential_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@ where
#[cfg(test)]
mod test {
use crate::credential_fn::provide_credentials_fn;
use crate::{
provider::{future, ProvideCredentials},
Credentials,
};
use async_trait::async_trait;
use std::fmt::{Debug, Formatter};
use crate::{provider::ProvideCredentials, Credentials};

fn assert_send_sync<T: Send + Sync>() {}

Expand All @@ -87,30 +82,6 @@ mod test {
assert_send_sync::<Credentials>()
}

#[async_trait]
trait AnotherTrait: Send + Sync {
async fn creds(&self) -> Credentials;
}

struct AnotherTraitWrapper<T> {
inner: T,
}

impl<T> Debug for AnotherTraitWrapper<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "wrapper")
}
}

impl<T: AnotherTrait> ProvideCredentials for AnotherTraitWrapper<T> {
fn provide_credentials<'a>(&'a self) -> future::ProvideCredentials<'a>
where
Self: 'a,
{
future::ProvideCredentials::new(async move { Ok(self.inner.creds().await) })
}
}

// Test that the closure passed to `provide_credentials_fn` is allowed to borrow things
#[tokio::test]
async fn provide_credentials_fn_closure_can_borrow() {
Expand Down
26 changes: 0 additions & 26 deletions aws/rust-runtime/aws-credential-types/src/token_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ where
mod test {
use super::*;
use crate::Token;
use async_trait::async_trait;
use std::fmt::{Debug, Formatter};

fn assert_send_sync<T: Send + Sync>() {}

Expand All @@ -83,30 +81,6 @@ mod test {
assert_send_sync::<Token>()
}

#[async_trait]
trait AnotherTrait: Send + Sync {
async fn token(&self) -> Token;
}

struct AnotherTraitWrapper<T> {
inner: T,
}

impl<T> Debug for AnotherTraitWrapper<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "wrapper")
}
}

impl<T: AnotherTrait> ProvideToken for AnotherTraitWrapper<T> {
fn provide_token<'a>(&'a self) -> future::ProvideToken<'a>
where
Self: 'a,
{
future::ProvideToken::new(async move { Ok(self.inner.token().await) })
}
}

// Test that the closure passed to `provide_token_fn` is allowed to borrow things
#[tokio::test]
async fn provide_token_fn_closure_can_borrow() {
Expand Down
1 change: 1 addition & 0 deletions aws/rust-runtime/aws-inlineable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub mod endpoint_discovery;
mod serialization_settings;

/// Parse the Expires and ExpiresString fields correctly
#[allow(dead_code)]
pub mod s3_expires_interceptor;

// just so docs work
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aws-runtime"
version = "1.4.1"
version = "1.4.2"
authors = ["AWS Rust SDK Team <[email protected]>"]
description = "Runtime support code for the AWS SDK. This crate isn't intended to be used directly."
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-runtime/src/env_config/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl Properties {
.entry(properties_key.clone())
.and_modify(|v| {
tracing::trace!("overwriting {properties_key}: was {v}, now {value}");
*v = value.clone();
v.clone_from(&value);
})
.or_insert(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ interface ModuleDocProvider {
}
try {
when {
module.documentationOverride != null -> writer.docs(module.documentationOverride)
module.documentationOverride != null -> {
if (module.documentationOverride.isNotEmpty()) {
writer.docs(module.documentationOverride)
}
}
else -> provider?.docsWriter(module)?.also { writeTo -> writeTo(writer) }
}
} catch (e: NotImplementedError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object TestWorkspace {
// help rust select the right version when we run cargo test
// TODO(https://github.com/smithy-lang/smithy-rs/issues/2048): load this from the msrv property using a
// method as we do for runtime crate versions
"[toolchain]\nchannel = \"1.76.0\"\n",
"[toolchain]\nchannel = \"1.78.0\"\n",
)
// ensure there at least an empty lib.rs file to avoid broken crates
newProject.resolve("src").mkdirs()
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

# Rust MSRV (entered into the generated README)
rust.msrv=1.76.0
rust.msrv=1.78.0

# To enable debug, swap out the two lines below.
# When changing this value, be sure to run `./gradlew --stop` to kill the Gradle daemon.
Expand Down
Loading

0 comments on commit 740edcc

Please sign in to comment.