Skip to content

Commit b0b575f

Browse files
DaniPopestyranron
andauthored
Lower MSRV to 1.65 (#313)
## Synopsis The MSRV bump in #300 is unnecessary. The 1.72 minimum is only needed for tests, but the actual implementation depends on 1.65. ## Solution - Lower MSRV from 1.72 to 1.65. - Omit tests requiring higher MSRV in `msrv` CI job. - Describe "MSRV policy" in README. Co-authored-by: Kai Ren <[email protected]>
1 parent a70c031 commit b0b575f

File tree

8 files changed

+48
-16
lines changed

8 files changed

+48
-16
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
strategy:
5555
fail-fast: false
5656
matrix:
57-
msrv: ["1.72.0"]
57+
msrv: ["1.65.0"]
5858
os:
5959
- ubuntu
6060
- macOS
@@ -74,6 +74,9 @@ jobs:
7474

7575
- run: cargo test --workspace --features full,testing-helpers
7676
-- --skip compile_fail
77+
env:
78+
RUSTFLAGS: --cfg msrv
79+
RUSTDOCFLAGS: --cfg msrv
7780

7881
no_std:
7982
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010

1111
### Breaking changes
1212

13-
- The minimum supported Rust version (MSRV) is now Rust 1.72.
13+
- The minimum supported Rust version (MSRV) is now Rust 1.65.
1414
- Add the `std` feature which should be disabled in `no_std` environments.
1515
- All Cargo features, except `std`, are now disabled by default. The `full`
1616
feature can be used to get the old behavior of supporting all possible

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "derive_more"
33
version = "1.0.0-beta.6"
44
edition = "2021"
5-
rust-version = "1.72.0"
5+
rust-version = "1.65.0"
66
description = "Adds #[derive(x)] macros for more traits"
77
authors = ["Jelte Fennema <[email protected]>"]
88
license = "MIT"

README.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Latest Version](https://img.shields.io/crates/v/derive_more.svg)](https://crates.io/crates/derive_more)
55
[![Rust Documentation](https://docs.rs/derive_more/badge.svg)](https://docs.rs/derive_more)
66
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/JelteF/derive_more/master/LICENSE)
7-
[![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)
7+
[![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)
88
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance)
99

1010
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.
137137
4. [`TryUnwrap`], for each variant `foo` of an enum type, derives an `try_unwrap_foo` method.
138138

139139

140+
### Re-exports
141+
142+
This crate also re-exports all the standard library traits that it adds derives
143+
for. So, both the `Display` derive and the `Display` trait will be in scope when
144+
you add the following code:
145+
```rust
146+
use derive_more::Display;
147+
```
148+
149+
140150

141151

142152
## Installation
143153

144-
This library requires Rust 1.72 or higher. To avoid redundant compilation times, by
145-
default no derives are supported. You have to enable each type of derive as a feature
146-
in `Cargo.toml`:
154+
To avoid redundant compilation times, by default no derives are supported.
155+
You have to enable each type of derive as a feature in `Cargo.toml`:
147156

148157
```toml
149158
[dependencies]
@@ -176,14 +185,25 @@ extern crate derive_more;
176185
# fn main() {} // omit wrapping statements above into `main()` in tests
177186
```
178187

179-
## Re-exports
180188

181-
This crate also re-exports all of the standard library traits that it adds
182-
derives for. So both the `Display` derive and the `Display` trait will be in
183-
scope when you add the following code:
184-
```rust
185-
use derive_more::Display;
186-
```
189+
## [MSRV] policy
190+
191+
This library requires Rust 1.65 or higher.
192+
193+
Changing [MSRV] (minimum supported Rust version) of this crate is treated as a **minor version change** in terms of [Semantic Versioning].
194+
- So, if [MSRV] changes are **NOT concerning** for your project, just use the default [caret requirement]:
195+
```toml
196+
[dependencies]
197+
derive_more = "1" # or "1.0", or "^1.0"
198+
```
199+
- However, if [MSRV] changes are concerning for your project, then use the [tilde requirement] to **omit breaking code**:
200+
```toml
201+
[dependencies]
202+
derive_more = "~1.0" # or "~1.0.0"
203+
```
204+
205+
206+
187207

188208
[`cargo-expand`]: https://github.com/dtolnay/cargo-expand
189209
[`derive-new`]: https://github.com/nrc/derive-new
@@ -216,3 +236,8 @@ use derive_more::Display;
216236
[`IsVariant`]: https://jeltef.github.io/derive_more/derive_more/is_variant.html
217237
[`Unwrap`]: https://jeltef.github.io/derive_more/derive_more/unwrap.html
218238
[`TryUnwrap`]: https://jeltef.github.io/derive_more/derive_more/try_unwrap.html
239+
240+
[caret requirement]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#caret-requirements
241+
[tilde requirement]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#tilde-requirements
242+
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
243+
[Semantic Versioning]: http://semver.org

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See full lints list at:
33
# https://rust-lang.github.io/rust-clippy/master/index.html
44

5-
msrv = "1.72.0"
5+
msrv = "1.65.0"
66

77
# Ensures consistent bracing for macro calls in the codebase.
88
# Extends default settings:

impl/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "derive_more-impl"
33
version = "1.0.0-beta.6"
44
edition = "2021"
5-
rust-version = "1.72.0"
5+
rust-version = "1.65.0"
66
description = "Internal implementation of `derive_more` crate"
77
authors = ["Jelte Fennema <[email protected]>"]
88
license = "MIT"

impl/doc/try_from.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The type can be changed with a `#[repr(u/i*)]` attribute, e.g., `#[repr(u8)]` or
1212
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.
1313

1414
```rust
15+
# #[cfg(msrv)] fn main() {} // TODO: Remove once MSRV bumps 1.66 or higher.
16+
# #[cfg(not(msrv))] fn main() {
1517
# use derive_more::TryFrom;
1618
#[derive(TryFrom, Debug, PartialEq)]
1719
#[try_from(repr)]
@@ -29,4 +31,5 @@ assert_eq!(Enum::EmptySeven{}, Enum::try_from(7).unwrap());
2931

3032
// Variants with fields are not supported, as the value for their fields would be undefined.
3133
assert!(Enum::try_from(6).is_err());
34+
# }
3235
```

tests/try_from.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fn enum_with_complex_repr() {
5656
assert!(Enum::try_from(-1).is_err());
5757
}
5858

59+
#[cfg(not(msrv))] // TODO: Remove once MSRV bumps 1.66 or higher.
5960
#[test]
6061
fn test_discriminants_on_enum_with_fields() {
6162
#[derive(TryFrom, Clone, Copy, Debug, Eq, PartialEq)]

0 commit comments

Comments
 (0)