From 5556afd5241d64aad9a853627a12d6c19d5f4a54 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 28 Nov 2021 01:19:57 +0000 Subject: [PATCH] fix bytestring test on older rust versions --- bytestring/Cargo.toml | 1 + bytestring/src/lib.rs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bytestring/Cargo.toml b/bytestring/Cargo.toml index d58af564..6be9eed2 100644 --- a/bytestring/Cargo.toml +++ b/bytestring/Cargo.toml @@ -25,3 +25,4 @@ serde = { version = "1.0", optional = true } ahash = { version = "0.7.6", default-features = false } serde_json = "1.0" static_assertions = "1.1" +rustversion = "1" diff --git a/bytestring/src/lib.rs b/bytestring/src/lib.rs index d9c5a253..ecf21c95 100644 --- a/bytestring/src/lib.rs +++ b/bytestring/src/lib.rs @@ -231,10 +231,7 @@ mod serde { #[cfg(test)] mod test { use alloc::borrow::ToOwned; - use core::{ - hash::{Hash, Hasher}, - panic::{RefUnwindSafe, UnwindSafe}, - }; + use core::hash::{Hash, Hasher}; use ahash::AHasher; use static_assertions::assert_impl_all; @@ -242,10 +239,19 @@ mod test { use super::*; assert_impl_all!(ByteString: Send, Sync, Unpin, Sized); - assert_impl_all!(ByteString: UnwindSafe, RefUnwindSafe); assert_impl_all!(ByteString: Clone, Default, Eq, PartialOrd, Ord); assert_impl_all!(ByteString: fmt::Debug, fmt::Display); + #[rustversion::since(1.56)] + mod above_1_56_impls { + // `[Ref]UnwindSafe` traits were only in std until rust 1.56 + + use core::panic::{RefUnwindSafe, UnwindSafe}; + + use super::*; + assert_impl_all!(ByteString: UnwindSafe, RefUnwindSafe); + } + #[test] fn test_partial_eq() { let s: ByteString = ByteString::from_static("test");