diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 778cb55..414f85f 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 @@ -74,6 +74,9 @@ jobs: - run: cargo test --workspace --features full,testing-helpers -- --skip compile_fail + env: + RUSTFLAGS: --cfg msrv + RUSTDOCFLAGS: --cfg msrv no_std: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 89ac783..7bfac31 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 6dd2b1e..dd244ec 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 324193b..5f29a76 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/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 @@ -137,13 +137,22 @@ 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 -This library requires Rust 1.72 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] @@ -176,14 +185,25 @@ 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; -``` +## [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 [`derive-new`]: https://github.com/nrc/derive-new @@ -216,3 +236,8 @@ use derive_more::Display; [`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 diff --git a/clippy.toml b/clippy.toml index 0d86a7d..0c697c3 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 f3274a2..a52ab74 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" diff --git a/impl/doc/try_from.md b/impl/doc/try_from.md index 7472689..41c2692 100644 --- a/impl/doc/try_from.md +++ b/impl/doc/try_from.md @@ -12,6 +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(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)] @@ -29,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()); +# } ``` diff --git a/tests/try_from.rs b/tests/try_from.rs index a44cdd0..25e5a8b 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)]