From 21012c40d138dbff7736e4ca19f667cb88a191f1 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 7 May 2024 17:04:40 +0000 Subject: [PATCH] Better support rustc 1.64+ by not requiring `RUSTC_BOOTSTRAP` --- src/http.rs | 3 +-- src/lib.rs | 3 +-- test.sh | 8 +++++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/http.rs b/src/http.rs index ab162c9..76c54c1 100644 --- a/src/http.rs +++ b/src/http.rs @@ -4,8 +4,7 @@ // const_slice_from_raw_parts was stabilized in 1.64, however we support building on 1.63 as well. // Luckily, it seems to work fine in 1.63 with the feature flag (and RUSTC_BOOTSTRAP=1) enabled. -#![cfg_attr(feature = "validation", allow(stable_features))] -#![cfg_attr(feature = "validation", feature(const_slice_from_raw_parts))] +#![cfg_attr(all(feature = "validation", rust_1_63), feature(const_slice_from_raw_parts))] extern crate alloc; diff --git a/src/lib.rs b/src/lib.rs index df9e45d..77c3cd9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,8 +35,7 @@ // const_slice_from_raw_parts was stabilized in 1.64, however we support building on 1.63 as well. // Luckily, it seems to work fine in 1.63 with the feature flag (and RUSTC_BOOTSTRAP=1) enabled. -#![allow(stable_features)] -#![feature(const_slice_from_raw_parts)] +#![cfg_attr(rust_1_63, feature(const_slice_from_raw_parts))] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/test.sh b/test.sh index 4d89ab0..b55143a 100755 --- a/test.sh +++ b/test.sh @@ -1,6 +1,12 @@ #!/bin/sh set -eox -export RUSTC_BOOTSTRAP=1 + +RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }') +if [ "$RUSTC_MINOR_VERSION" = 63 ]; then + export RUSTC_BOOTSTRAP=1 + export RUSTFLAGS=--cfg=rust_1_63 +fi + cargo test --no-default-features cargo test cargo test --no-default-features --features std -- 2.39.5