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 5, 2025
1 parent 4d65cc8 commit 8727b9c
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 @@ -204,6 +207,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 @@ -212,6 +216,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 @@ -220,6 +225,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 @@ -244,6 +250,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 @@ -260,6 +267,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 @@ -268,6 +276,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 @@ -276,6 +285,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 @@ -344,6 +354,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 @@ -501,6 +512,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 @@ -511,6 +523,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 @@ -521,6 +534,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 @@ -531,6 +545,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 @@ -577,6 +592,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 @@ -609,6 +625,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 @@ -617,6 +634,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 @@ -625,6 +643,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 @@ -634,6 +653,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 8727b9c

Please sign in to comment.