Skip to content

Commit

Permalink
Add #[cfg(not(test))] to some impls to work around #135100
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtriplett committed Jan 4, 2025
1 parent 0af18ca commit 4bb581c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions library/alloc/src/bstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ use core::ops::{
Deref, DerefMut, DerefPure, Index, IndexMut, Range, RangeFrom, RangeFull, RangeInclusive,
RangeTo, RangeToInclusive,
};
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
use core::str::FromStr;
use core::{fmt, hash};

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
use crate::borrow::{Cow, ToOwned};
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
use crate::boxed::Box;
use crate::rc::Rc;
use crate::string::String;
Expand Down Expand Up @@ -202,6 +205,7 @@ impl Default for ByteString {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl<'a, const N: usize> From<&'a [u8; N]> for ByteString {
#[inline]
Expand All @@ -210,6 +214,7 @@ impl<'a, const N: usize> From<&'a [u8; N]> for ByteString {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl<const N: usize> From<[u8; N]> for ByteString {
#[inline]
Expand All @@ -218,6 +223,7 @@ impl<const N: usize> From<[u8; N]> for ByteString {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> From<&'a [u8]> for ByteString {
#[inline]
Expand All @@ -242,6 +248,7 @@ impl From<ByteString> for Vec<u8> {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> From<&'a str> for ByteString {
#[inline]
Expand All @@ -258,6 +265,7 @@ impl From<String> for ByteString {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> From<&'a ByteStr> for ByteString {
#[inline]
Expand All @@ -266,6 +274,7 @@ impl<'a> From<&'a ByteStr> for ByteString {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> From<ByteString> for Cow<'a, ByteStr> {
#[inline]
Expand All @@ -274,6 +283,7 @@ impl<'a> From<ByteString> for Cow<'a, ByteStr> {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> From<&'a ByteString> for Cow<'a, ByteStr> {
#[inline]
Expand Down Expand Up @@ -342,6 +352,7 @@ impl FromIterator<ByteString> for ByteString {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl FromStr for ByteString {
type Err = core::convert::Infallible;
Expand Down Expand Up @@ -499,6 +510,7 @@ impl PartialEq for ByteString {

macro_rules! impl_partial_eq_ord_cow {
($lhs:ty, $rhs:ty) => {
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[allow(unused_lifetimes)]
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> PartialEq<$rhs> for $lhs {
Expand All @@ -509,6 +521,7 @@ macro_rules! impl_partial_eq_ord_cow {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[allow(unused_lifetimes)]
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> PartialEq<$lhs> for $rhs {
Expand All @@ -519,6 +532,7 @@ macro_rules! impl_partial_eq_ord_cow {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[allow(unused_lifetimes)]
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> PartialOrd<$rhs> for $lhs {
Expand All @@ -529,6 +543,7 @@ macro_rules! impl_partial_eq_ord_cow {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[allow(unused_lifetimes)]
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> PartialOrd<$lhs> for $rhs {
Expand Down Expand Up @@ -571,6 +586,7 @@ impl PartialOrd for ByteString {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl ToOwned for ByteStr {
type Owned = ByteString;
Expand Down Expand Up @@ -603,6 +619,7 @@ impl<'a> TryFrom<&'a ByteString> for &'a str {

// Additional impls for `ByteStr` that require types from `alloc`:

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl Clone for Box<ByteStr> {
#[inline]
Expand All @@ -611,6 +628,7 @@ impl Clone for Box<ByteStr> {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
#[inline]
Expand All @@ -619,6 +637,7 @@ impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl From<Box<[u8]>> for Box<ByteStr> {
#[inline]
Expand All @@ -628,6 +647,7 @@ impl From<Box<[u8]>> for Box<ByteStr> {
}
}

#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
#[unstable(feature = "bstr", issue = "134915")]
impl From<Box<ByteStr>> for Box<[u8]> {
#[inline]
Expand Down

0 comments on commit 4bb581c

Please sign in to comment.