From 1ca2b469718c0c7e2a6255840e0e5cddedb3f34a Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Tue, 28 Sep 2021 09:08:23 -0400 Subject: [PATCH] Increase MSRV to 1.53.0 (#730) * Make to_* fns take self by value * Changelog update * Fix 2 missing autolinks * Allow bare urls in generated code --- .github/workflows/ci.yaml | 2 +- CHANGELOG.md | 4 ++++ aws/SDK_CHANGELOG.md | 5 +++++ .../aws-config/src/meta/credentials/chain.rs | 2 +- .../aws-config/src/profile/credentials/exec.rs | 6 ++---- aws/rust-runtime/aws-types/src/os_shim_internal.rs | 1 - aws/rust-runtime/aws-types/src/region.rs | 2 +- aws/sdk/examples/dynamodb/src/bin/movies.rs | 3 ++- ...ClippyLintsGenerator.kt => AllowLintsGenerator.kt} | 11 ++++++++++- .../smithy/customize/RequiredCustomizations.kt | 4 ++-- rust-runtime/smithy-types/src/instant/mod.rs | 8 ++++---- rust-runtime/smithy-types/src/lib.rs | 10 +++++----- 12 files changed, 37 insertions(+), 21 deletions(-) rename codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/{AllowClippyLintsGenerator.kt => AllowLintsGenerator.kt} (79%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d59e28c0d..3c34a479d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ on: name: CI env: - rust_version: 1.52.1 + rust_version: 1.53.0 rust_toolchain_components: clippy,rustfmt java_version: 11 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f7415d01..91314d2e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ vNext (Month Day, Year) ======================= +**Breaking changes** +- :warning: MSRV increased from 1.52.1 to 1.53.0 per our 3-behind MSRV policy. + +**New this week** - :bug: Fix an issue where `smithy-xml` may have generated invalid XML (smithy-rs#719) v0.24 (September 24th, 2021) diff --git a/aws/SDK_CHANGELOG.md b/aws/SDK_CHANGELOG.md index cc910f676..a421546fc 100644 --- a/aws/SDK_CHANGELOG.md +++ b/aws/SDK_CHANGELOG.md @@ -1,5 +1,10 @@ vNext (Month Day, Year) ======================= +**Breaking changes** +- :warning: MSRV increased from 1.52.1 to 1.53.0 per our 3-behind MSRV policy. + +**Tasks to cut release** +- [ ] Bump MSRV on aws-sdk-rust, then delete this line. v0.0.19-alpha (September 24th, 2021) ==================================== 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 9e053ea09..b37a1da62 100644 --- a/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs +++ b/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs @@ -90,7 +90,7 @@ impl CredentialsProviderChain { } } } - return Err(CredentialsError::CredentialsNotLoaded); + Err(CredentialsError::CredentialsNotLoaded) } } diff --git a/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs b/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs index f8fc8b8fb..ef50a8e8b 100644 --- a/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs +++ b/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs @@ -151,12 +151,10 @@ pub mod named { } fn lower_cow(mut inp: Cow) -> Cow { - if inp.chars().all(|c| c.is_ascii_lowercase()) { - inp - } else { + if !inp.chars().all(|c| c.is_ascii_lowercase()) { inp.to_mut().make_ascii_lowercase(); - inp } + inp } impl NamedProviderFactory { diff --git a/aws/rust-runtime/aws-types/src/os_shim_internal.rs b/aws/rust-runtime/aws-types/src/os_shim_internal.rs index 2de9e19b6..8bb19554a 100644 --- a/aws/rust-runtime/aws-types/src/os_shim_internal.rs +++ b/aws/rust-runtime/aws-types/src/os_shim_internal.rs @@ -261,7 +261,6 @@ impl Default for TimeSource { /// let client = Client::with_timesource(TimeSource::manual(&time)); /// time.advance(Duration::from_secs(100)); /// ``` -/// ``` #[derive(Clone, Debug)] pub struct ManualTimeSource { queries: Arc>>, diff --git a/aws/rust-runtime/aws-types/src/region.rs b/aws/rust-runtime/aws-types/src/region.rs index 821f21c19..c1c21ae8c 100644 --- a/aws/rust-runtime/aws-types/src/region.rs +++ b/aws/rust-runtime/aws-types/src/region.rs @@ -12,7 +12,7 @@ use std::fmt::{Display, Formatter}; /// per-client basis unless otherwise noted. A full list of regions is found in the /// "Regions and Endpoints" document. /// -/// See http://docs.aws.amazon.com/general/latest/gr/rande.html for +/// See for /// information on AWS regions. #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct Region( diff --git a/aws/sdk/examples/dynamodb/src/bin/movies.rs b/aws/sdk/examples/dynamodb/src/bin/movies.rs index 5751e4ac9..a6abb7108 100644 --- a/aws/sdk/examples/dynamodb/src/bin/movies.rs +++ b/aws/sdk/examples/dynamodb/src/bin/movies.rs @@ -40,7 +40,8 @@ struct Opt { verbose: bool, } -/// A partial reimplementation of https://docs.amazonaws.cn/en_us/amazondynamodb/latest/developerguide/GettingStarted.Ruby.html +/// A partial reimplementation of +/// /// in Rust /// /// - Create table diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/AllowClippyLintsGenerator.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/AllowLintsGenerator.kt similarity index 79% rename from codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/AllowClippyLintsGenerator.kt rename to codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/AllowLintsGenerator.kt index c1bdd101e..8014f80ba 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/AllowClippyLintsGenerator.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/AllowLintsGenerator.kt @@ -33,12 +33,21 @@ val ClippyAllowLints = listOf( "vec_init_then_push", ) -class AllowClippyLints : LibRsCustomization() { +val AllowDocsLints = listOf( + // Rust >=1.53.0 requires links to be wrapped in ``. This is extremely hard to enforce for + // docs that come from the modeled documentation, so we need to disable this lint + "bare_urls" +) + +class AllowLintsGenerator : LibRsCustomization() { override fun section(section: LibRsSection) = when (section) { is LibRsSection.Attributes -> writable { ClippyAllowLints.forEach { Attribute.Custom("allow(clippy::$it)", container = true).render(this) } + AllowDocsLints.forEach { + Attribute.Custom("allow(rustdoc::$it)", container = true).render(this) + } // add a newline at the end this.write("") } diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customize/RequiredCustomizations.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customize/RequiredCustomizations.kt index 847348e2c..b60f2f697 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customize/RequiredCustomizations.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customize/RequiredCustomizations.kt @@ -6,7 +6,7 @@ package software.amazon.smithy.rust.codegen.smithy.customize import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rust.codegen.smithy.customizations.AllowClippyLints +import software.amazon.smithy.rust.codegen.smithy.customizations.AllowLintsGenerator import software.amazon.smithy.rust.codegen.smithy.customizations.CrateVersionGenerator import software.amazon.smithy.rust.codegen.smithy.customizations.EndpointPrefixGenerator import software.amazon.smithy.rust.codegen.smithy.customizations.HttpChecksumRequiredGenerator @@ -38,6 +38,6 @@ class RequiredCustomizations : RustCodegenDecorator { protocolConfig: ProtocolConfig, baseCustomizations: List ): List { - return baseCustomizations + CrateVersionGenerator() + SmithyTypesPubUseGenerator(protocolConfig.runtimeConfig) + AllowClippyLints() + return baseCustomizations + CrateVersionGenerator() + SmithyTypesPubUseGenerator(protocolConfig.runtimeConfig) + AllowLintsGenerator() } } diff --git a/rust-runtime/smithy-types/src/instant/mod.rs b/rust-runtime/smithy-types/src/instant/mod.rs index 3274ac9cc..007b4c0dd 100644 --- a/rust-runtime/smithy-types/src/instant/mod.rs +++ b/rust-runtime/smithy-types/src/instant/mod.rs @@ -100,11 +100,11 @@ impl Instant { } #[cfg(feature = "chrono-conversions")] - pub fn to_chrono(&self) -> DateTime { + pub fn to_chrono(self) -> DateTime { self.to_chrono_internal() } - fn to_chrono_internal(&self) -> DateTime { + fn to_chrono_internal(self) -> DateTime { DateTime::::from_utc( NaiveDateTime::from_timestamp(self.seconds, self.subsecond_nanos), Utc, @@ -115,7 +115,7 @@ impl Instant { /// /// Since SystemTime cannot represent times prior to the unix epoch, if this time is before /// 1/1/1970, this function will return `None`. - pub fn to_system_time(&self) -> Option { + pub fn to_system_time(self) -> Option { if self.seconds < 0 { None } else { @@ -146,7 +146,7 @@ impl Instant { /// Converts the `Instant` to the number of milliseconds since the Unix epoch. /// This is fallible since `Instant` holds more precision than an `i64`, and will /// return a `ConversionError` for `Instant` values that can't be converted. - pub fn to_epoch_millis(&self) -> Result { + pub fn to_epoch_millis(self) -> Result { let subsec_millis = Integer::div_floor(&i64::from(self.subsecond_nanos), &(NANOS_PER_MILLI as i64)); if self.seconds < 0 { diff --git a/rust-runtime/smithy-types/src/lib.rs b/rust-runtime/smithy-types/src/lib.rs index 1bcfd42c1..fd8082cf7 100644 --- a/rust-runtime/smithy-types/src/lib.rs +++ b/rust-runtime/smithy-types/src/lib.rs @@ -53,7 +53,7 @@ pub enum Document { } /// A number type that implements Javascript / JSON semantics, modeled on serde_json: -/// https://docs.serde.rs/src/serde_json/number.rs.html#20-22 +/// #[derive(Debug, Clone, Copy, PartialEq)] pub enum Number { PosInt(u64), @@ -64,11 +64,11 @@ pub enum Number { macro_rules! to_num_fn { ($name:ident, $typ:ident) => { /// Converts to a `$typ`. This conversion may be lossy. - pub fn $name(&self) -> $typ { + pub fn $name(self) -> $typ { match self { - Number::PosInt(val) => *val as $typ, - Number::NegInt(val) => *val as $typ, - Number::Float(val) => *val as $typ, + Number::PosInt(val) => val as $typ, + Number::NegInt(val) => val as $typ, + Number::Float(val) => val as $typ, } } }; -- GitLab