From 2ce91ba28e49d2475c27da3f1ce2c977abf001fa Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 11 Nov 2023 11:22:30 +0100 Subject: [PATCH 1/7] Lower MSRV to 1.65 The MSRV bump in https://github.com/JelteF/derive_more/pull/300 is unnecessary. The 1.72 minimum is only needed for tests, but the actual implementation depends on 1.65. --- .github/workflows/ci.yml | 5 ++--- CHANGELOG.md | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- clippy.toml | 2 +- impl/Cargo.toml | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 778cb558..af55e52d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: strategy: fail-fast: false matrix: - msrv: ["1.72.0"] + msrv: ["1.65.0"] os: - ubuntu - macOS @@ -72,8 +72,7 @@ jobs: - name: Install minimal dependencies versions run: cargo +nightly update -Z minimal-versions - - run: cargo test --workspace --features full,testing-helpers - -- --skip compile_fail + - run: cargo build --workspace --features full no_std: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 89ac783c..7bfac31b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Breaking changes -- The minimum supported Rust version (MSRV) is now Rust 1.72. +- The minimum supported Rust version (MSRV) is now Rust 1.65. - Add the `std` feature which should be disabled in `no_std` environments. - All Cargo features, except `std`, are now disabled by default. The `full` feature can be used to get the old behavior of supporting all possible diff --git a/Cargo.toml b/Cargo.toml index 6dd2b1e8..dd244ec9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "derive_more" version = "1.0.0-beta.6" edition = "2021" -rust-version = "1.72.0" +rust-version = "1.65.0" description = "Adds #[derive(x)] macros for more traits" authors = ["Jelte Fennema "] license = "MIT" diff --git a/README.md b/README.md index 324193bc..70344f64 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Latest Version](https://img.shields.io/crates/v/derive_more.svg)](https://crates.io/crates/derive_more) [![Rust Documentation](https://docs.rs/derive_more/badge.svg)](https://docs.rs/derive_more) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/JelteF/derive_more/master/LICENSE) -[![Rust 1.72+](https://img.shields.io/badge/rustc-1.72+-lightgray.svg)](https://blog.rust-lang.org/2023/08/24/Rust-1.72.0.html) +[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg)](https://blog.rust-lang.org/2023/08/24/Rust-1.65.0.html) [![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance) Rust has lots of builtin traits that are implemented for its basic types, such @@ -141,7 +141,7 @@ These don't derive traits, but derive static methods instead. ## Installation -This library requires Rust 1.72 or higher. To avoid redundant compilation times, by +This library requires Rust 1.65 or higher. To avoid redundant compilation times, by default no derives are supported. You have to enable each type of derive as a feature in `Cargo.toml`: diff --git a/clippy.toml b/clippy.toml index 0d86a7d2..0c697c31 100644 --- a/clippy.toml +++ b/clippy.toml @@ -2,7 +2,7 @@ # See full lints list at: # https://rust-lang.github.io/rust-clippy/master/index.html -msrv = "1.72.0" +msrv = "1.65.0" # Ensures consistent bracing for macro calls in the codebase. # Extends default settings: diff --git a/impl/Cargo.toml b/impl/Cargo.toml index c51136dd..548ee245 100644 --- a/impl/Cargo.toml +++ b/impl/Cargo.toml @@ -2,7 +2,7 @@ name = "derive_more-impl" version = "1.0.0-beta.6" edition = "2021" -rust-version = "1.72.0" +rust-version = "1.65.0" description = "Internal implementation of `derive_more` crate" authors = ["Jelte Fennema "] license = "MIT" From 76930e1ac369eb6753d3fcbc7240ab607926995a Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 13 Nov 2023 15:58:00 +0100 Subject: [PATCH 2/7] Switch `cargo build` to `cargo check` for MSRV CI check --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af55e52d..1e1e43fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: - name: Install minimal dependencies versions run: cargo +nightly update -Z minimal-versions - - run: cargo build --workspace --features full + - run: cargo check --workspace --features full no_std: runs-on: ubuntu-latest From 44a1516c2bd0d5208b5b11ee266f916642430a11 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 4 Dec 2023 16:38:36 +0100 Subject: [PATCH 3/7] Move "Re-exports" section in README --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 70344f64..33530ea3 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,16 @@ These don't derive traits, but derive static methods instead. 4. [`TryUnwrap`], for each variant `foo` of an enum type, derives an `try_unwrap_foo` method. +### Re-exports + +This crate also re-exports all the standard library traits that it adds derives +for. So, both the `Display` derive and the `Display` trait will be in scope when +you add the following code: +```rust +use derive_more::Display; +``` + + ## Installation @@ -176,14 +186,8 @@ extern crate derive_more; # fn main() {} // omit wrapping statements above into `main()` in tests ``` -## Re-exports -This crate also re-exports all of the standard library traits that it adds -derives for. So both the `Display` derive and the `Display` trait will be in -scope when you add the following code: -```rust -use derive_more::Display; -``` + [`cargo-expand`]: https://github.com/dtolnay/cargo-expand [`derive-new`]: https://github.com/nrc/derive-new From 55019b7d1f458a7d13a9e4bacdef771c95ade1d0 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 4 Dec 2023 16:58:22 +0100 Subject: [PATCH 4/7] Describe MSRV policy in README --- README.md | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 33530ea3..5f29a76d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Latest Version](https://img.shields.io/crates/v/derive_more.svg)](https://crates.io/crates/derive_more) [![Rust Documentation](https://docs.rs/derive_more/badge.svg)](https://docs.rs/derive_more) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/JelteF/derive_more/master/LICENSE) -[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg)](https://blog.rust-lang.org/2023/08/24/Rust-1.65.0.html) +[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg)](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html) [![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance) Rust has lots of builtin traits that are implemented for its basic types, such @@ -151,9 +151,8 @@ use derive_more::Display; ## Installation -This library requires Rust 1.65 or higher. To avoid redundant compilation times, by -default no derives are supported. You have to enable each type of derive as a feature -in `Cargo.toml`: +To avoid redundant compilation times, by default no derives are supported. +You have to enable each type of derive as a feature in `Cargo.toml`: ```toml [dependencies] @@ -187,6 +186,23 @@ extern crate derive_more; ``` +## [MSRV] policy + +This library requires Rust 1.65 or higher. + +Changing [MSRV] (minimum supported Rust version) of this crate is treated as a **minor version change** in terms of [Semantic Versioning]. +- So, if [MSRV] changes are **NOT concerning** for your project, just use the default [caret requirement]: + ```toml + [dependencies] + derive_more = "1" # or "1.0", or "^1.0" + ``` +- However, if [MSRV] changes are concerning for your project, then use the [tilde requirement] to **omit breaking code**: + ```toml + [dependencies] + derive_more = "~1.0" # or "~1.0.0" + ``` + + [`cargo-expand`]: https://github.com/dtolnay/cargo-expand @@ -220,3 +236,8 @@ extern crate derive_more; [`IsVariant`]: https://jeltef.github.io/derive_more/derive_more/is_variant.html [`Unwrap`]: https://jeltef.github.io/derive_more/derive_more/unwrap.html [`TryUnwrap`]: https://jeltef.github.io/derive_more/derive_more/try_unwrap.html + +[caret requirement]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#caret-requirements +[tilde requirement]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#tilde-requirements +[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field +[Semantic Versioning]: http://semver.org From 4b29bd17ebb62e539b436749796ed38594f90749 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 4 Dec 2023 17:02:34 +0100 Subject: [PATCH 5/7] Run tests for MSRV --- .github/workflows/ci.yml | 5 ++++- tests/try_from.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e1e43fa..a22d9e16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,10 @@ jobs: - name: Install minimal dependencies versions run: cargo +nightly update -Z minimal-versions - - run: cargo check --workspace --features full + - run: cargo test --workspace --features full,testing-helpers + -- --skip compile_fail + env: + RUSTFLAGS: --cfg msrv no_std: runs-on: ubuntu-latest diff --git a/tests/try_from.rs b/tests/try_from.rs index a44cdd07..25e5a8b9 100644 --- a/tests/try_from.rs +++ b/tests/try_from.rs @@ -56,6 +56,7 @@ fn enum_with_complex_repr() { assert!(Enum::try_from(-1).is_err()); } +#[cfg(not(msrv))] // TODO: Remove once MSRV bumps 1.66 or higher. #[test] fn test_discriminants_on_enum_with_fields() { #[derive(TryFrom, Clone, Copy, Debug, Eq, PartialEq)] From 1c29021cab6c7e3c1d3862b58ce65b22dd3f9d99 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 4 Dec 2023 17:43:09 +0100 Subject: [PATCH 6/7] Fix tests in docs --- .github/workflows/ci.yml | 1 + impl/doc/try_from.md | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a22d9e16..414f85fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,6 +76,7 @@ jobs: -- --skip compile_fail env: RUSTFLAGS: --cfg msrv + RUSTDOCFLAGS: --cfg msrv no_std: runs-on: ubuntu-latest diff --git a/impl/doc/try_from.md b/impl/doc/try_from.md index 7472689f..e386af0d 100644 --- a/impl/doc/try_from.md +++ b/impl/doc/try_from.md @@ -12,6 +12,7 @@ The type can be changed with a `#[repr(u/i*)]` attribute, e.g., `#[repr(u8)]` or Only field-less variants can be constructed from their variant, therefor the `TryFrom` implementation will return an error for a discriminant representing a variant with fields. ```rust +# #![cfg(not(msrv))] // TODO: Remove once MSRV bumps 1.66 or higher. # use derive_more::TryFrom; #[derive(TryFrom, Debug, PartialEq)] #[try_from(repr)] From 4cba920a331a19ca27282b22136fca34df50aa77 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 4 Dec 2023 17:49:19 +0100 Subject: [PATCH 7/7] Fix tests in docs, vol.2 --- impl/doc/try_from.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/impl/doc/try_from.md b/impl/doc/try_from.md index e386af0d..41c2692a 100644 --- a/impl/doc/try_from.md +++ b/impl/doc/try_from.md @@ -12,7 +12,8 @@ The type can be changed with a `#[repr(u/i*)]` attribute, e.g., `#[repr(u8)]` or Only field-less variants can be constructed from their variant, therefor the `TryFrom` implementation will return an error for a discriminant representing a variant with fields. ```rust -# #![cfg(not(msrv))] // TODO: Remove once MSRV bumps 1.66 or higher. +# #[cfg(msrv)] fn main() {} // TODO: Remove once MSRV bumps 1.66 or higher. +# #[cfg(not(msrv))] fn main() { # use derive_more::TryFrom; #[derive(TryFrom, Debug, PartialEq)] #[try_from(repr)] @@ -30,4 +31,5 @@ assert_eq!(Enum::EmptySeven{}, Enum::try_from(7).unwrap()); // Variants with fields are not supported, as the value for their fields would be undefined. assert!(Enum::try_from(6).is_err()); +# } ```