Better support rustc 1.64+ by not requiring `RUSTC_BOOTSTRAP`
authorMatt Corallo <git@bluematt.me>
Tue, 7 May 2024 17:04:40 +0000 (17:04 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 7 May 2024 17:30:52 +0000 (17:30 +0000)
src/http.rs
src/lib.rs
test.sh

index ab162c94e68f2e5d65c9adfcbcd7f3cfb723250f..76c54c1b02b8e43c341c0ef52a725eead8d32683 100644 (file)
@@ -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;
 
index df9e45d859c29a1e0160c355d6da65c5679647c1..77c3cd94695e0a2d76f78aeb263a5567e7cb8554 100644 (file)
@@ -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 4d89ab0233fe1cfd82b8f22a16d0a31a41b4799d..b55143a235e749f0de5e0269aaceb7981668c194 100755 (executable)
--- 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