chore: Set `rust-version` in `Cargo.toml`
Maintaining an appropriate rust-version will better support downstreams resolving dependencies with compatible releases via -Z msrv-policy (or the eventual stabilized equivalent).
Context
Looks like the minimum supported version is Rust 1.63.0, at least when opt-out of the default features (std); otherwise it's Rust 1.64.0.
For reference hashbrown 0.14.2 release relaxed their MSRV from 1.64.0 to 1.63:
- Provided that this crate is pinned to
0.2.9(0.2.10is compatible too) or the related default feature in hashbrown is disabled. - This was to allow current Debian stable to build
hashbrownwith Rust 1.63.
In future, if this sort of change happens it could be better resolved if rust-version was adopted instead. Presently without updating Cargo.lock with a pin for hashbrown, the implicit allocator-api2 dep will resolve to a version incompatible with rust-version = "1.63.0", but -Z msrv-policy won't be able to infer that due to lack of rust-version.
allocator-api2 should likewise adopt rust-version.
-
1.64.0might go more smoothly in the ecosystem (Preferred). -
1.63.0is more accurate and may avoid adding friction.
If preferring rust-version = "1.64.0", it should rollback to the prior release when this condition is not satisfied (eg: -Z msrv-policy). Thus only a concern if downstreams still expect to compile newer releases with 1.63.0?
For context the 0.2.9 release was 1.63.0 regardless of std vs nostd builds below.
Reproduction with cargo-msrv
std (default) => MSRV 1.64
[package]
name = "reproduction"
version = "0.1.0"
edition = "2021"
[dependencies]
allocator-api2 = "0.2.16"
fn main() {
println!("Hello, world!");
}
$ cargo-msrv --max 1.64.0
Check for toolchain '1.63.0-x86_64-unknown-linux-gnu' failed with:
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Checking allocator-api2 v0.2.16 │
│ error[E0658]: use of unstable library feature 'core_c_str' │
│ --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/allocator-api2-0.2.16/src/stable/boxed.rs:2115:20 │
│ | │
│ 2115 | impl Clone for Box<core::ffi::CStr> { │
│ | ^^^^^^^^^^^^^^^ │
│ | │
│ = note: see issue #94079 <https://github.com/rust-lang/rust/issues/94079> for more information │
│ │
│ error[E0658]: use of unstable library feature 'core_c_str' │
│ --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/allocator-api2-0.2.16/src/stable/boxed.rs:2123:12 │
│ | │
│ 2123 | impl From<&core::ffi::CStr> for Box<core::ffi::CStr> { │
│ | ^^^^^^^^^^^^^^^ │
│ | │
│ = note: see issue #94079 <https://github.com/rust-lang/rust/issues/94079> for more information │
│ │
│ error[E0658]: use of unstable library feature 'core_c_str' │
│ --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/allocator-api2-0.2.16/src/stable/boxed.rs:2123:37 │
│ | │
│ 2123 | impl From<&core::ffi::CStr> for Box<core::ffi::CStr> { │
│ | ^^^^^^^^^^^^^^^ │
│ | │
│ = note: see issue #94079 <https://github.com/rust-lang/rust/issues/94079> for more information │
│ │
│ error[E0658]: use of unstable library feature 'core_c_str' │
│ --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/allocator-api2-0.2.16/src/stable/boxed.rs:2126:17 │
│ | │
│ 2126 | fn from(s: &core::ffi::CStr) -> Box<core::ffi::CStr> { │
│ | ^^^^^^^^^^^^^^^ │
│ | │
│ = note: see issue #94079 <https://github.com/rust-lang/rust/issues/94079> for more information │
│ │
│ error[E0658]: use of unstable library feature 'core_c_str' │
│ --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/allocator-api2-0.2.16/src/stable/boxed.rs:2126:41 │
│ | │
│ 2126 | fn from(s: &core::ffi::CStr) -> Box<core::ffi::CStr> { │
│ | ^^^^^^^^^^^^^^^ │
│ | │
│ = note: see issue #94079 <https://github.com/rust-lang/rust/issues/94079> for more information │
│ │
│ error[E0658]: use of unstable library feature 'core_c_str' │
│ --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/allocator-api2-0.2.16/src/stable/boxed.rs:2128:61 │
│ | │
│ 2128 | unsafe { Box::from_raw(Box::into_raw(boxed) as *mut core::ffi::CStr) } │
│ | ^^^^^^^^^^^^^^^ │
│ | │
│ = note: see issue #94079 <https://github.com/rust-lang/rust/issues/94079> for more information │
│ │
│ For more information about this error, try `rustc --explain E0658`. │
│ error: could not compile `allocator-api2` due to 6 previous errors │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Check for toolchain '1.64.0-x86_64-unknown-linux-gnu' succeeded
Finished The MSRV is: 1.64.0 ████████████████████████████████████████████████████████████████████████████████████████ 00:00:01
nostd (default-features = false) => MSRV 1.63
[package]
name = "reproduction"
version = "0.1.0"
edition = "2021"
[dependencies]
# opt-out of default `std` feature:
allocator-api2 = { version = "0.2.16", default-features = false }
#![no_main]
#![no_std]
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_panic: &PanicInfo<'_>) -> ! {
loop {}
}
# Make cargo-msrv happy:
$ rustup target add x86_64-unknown-none
$ rustup target add --toolchain 1.64.0 x86_64-unknown-none
$ rustup target add --toolchain 1.63.0 x86_64-unknown-none
$ rustup target add --toolchain 1.62.1 x86_64-unknown-none
# Verify:
$ cargo-msrv --max 1.64.0 -- cargo check --target x86_64-unknown-none
Check for toolchain '1.62.1-x86_64-unknown-linux-gnu' failed with:
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Checking allocator-api2 v0.2.16 │
│ error[E0658]: use of unstable library feature 'slice_ptr_len' │
│ --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/allocator-api2-0.2.16/src/stable/alloc/mod.rs:143:63 │
│ | │
│ 143 | unsafe { ptr.cast::<u8>().as_ptr().write_bytes(0, ptr.len()) } │
│ | ^^^ │
│ | │
│ = note: see issue #71146 <https://github.com/rust-lang/rust/issues/71146> for more information │
│ │
│ For more information about this error, try `rustc --explain E0658`. │
│ error: could not compile `allocator-api2` due to previous error │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Check for toolchain '1.63.0-x86_64-unknown-linux-gnu' succeeded
Finished The MSRV is: 1.63.0 ████████████████████████████████████████████████████████████████████████████████████████ 00:00:01
@zakarumych is there any reason this PR has been ignored?
The only reason is that I was overwhelmed when it was created and forgot to get back to it.
I believe the change is still relevant, so I'll merge it.
Do you need ew patch version release?
Do you need ew patch version release?
I'm in no rush 👍 Just a friendly ping.
If you're going to merge, please consider one of the two suggestions provided above. 1.63.0 (with additional comment for context) or 1.64.0.
Thank you for contribution.