about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2025-01-12 12:27:24 +0200
committerJosh Triplett <josh@joshtriplett.org>2025-01-12 12:27:24 +0200
commit22a4ec39fbb53fd39179961a19c643d600bbeebd (patch)
tree8bd18fd93aaacb098ee6e9c6d89e786a0e5b1ffc
parent76780fa10e9e449bdd68d773041f85a64303bb02 (diff)
downloadrust-22a4ec39fbb53fd39179961a19c643d600bbeebd.tar.gz
rust-22a4ec39fbb53fd39179961a19c643d600bbeebd.zip
Omit some more `From` impls to avoid inference failures
-rw-r--r--library/alloc/src/bstr.rs119
-rw-r--r--library/core/src/bstr.rs48
2 files changed, 80 insertions, 87 deletions
diff --git a/library/alloc/src/bstr.rs b/library/alloc/src/bstr.rs
index f16a36b0f9b..acb60d9ca86 100644
--- a/library/alloc/src/bstr.rs
+++ b/library/alloc/src/bstr.rs
@@ -43,21 +43,6 @@ use crate::vec::Vec;
 ///
 /// The `Debug` and `Display` implementations for `ByteString` are the same as those for `ByteStr`,
 /// showing invalid UTF-8 as hex escapes or the Unicode replacement character, respectively.
-///
-/// # Examples
-///
-/// You can create a new `ByteString` from a `Vec<u8>` directly, or via a `From` impl from various
-/// string types:
-///
-/// ```
-/// # #![feature(bstr)]
-/// # use std::bstr::ByteString;
-/// let s1 = ByteString(vec![b'H', b'e', b'l', b'l', b'o']);
-/// let s2 = ByteString::from("Hello");
-/// let s3 = ByteString::from(b"Hello");
-/// assert_eq!(s1, s2);
-/// assert_eq!(s2, s3);
-/// ```
 #[unstable(feature = "bstr", issue = "134915")]
 #[repr(transparent)]
 #[derive(Clone)]
@@ -193,40 +178,42 @@ 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]
-    fn from(s: &'a [u8; N]) -> Self {
-        ByteString(s.as_slice().to_vec())
-    }
-}
-
-#[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]
-    fn from(s: [u8; N]) -> Self {
-        ByteString(s.as_slice().to_vec())
-    }
-}
-
-#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
-#[unstable(feature = "bstr", issue = "134915")]
-impl<'a> From<&'a [u8]> for ByteString {
-    #[inline]
-    fn from(s: &'a [u8]) -> Self {
-        ByteString(s.to_vec())
-    }
-}
-
-#[unstable(feature = "bstr", issue = "134915")]
-impl From<Vec<u8>> for ByteString {
-    #[inline]
-    fn from(s: Vec<u8>) -> Self {
-        ByteString(s)
-    }
-}
+// Omitted due to inference failures
+//
+// #[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]
+//     fn from(s: &'a [u8; N]) -> Self {
+//         ByteString(s.as_slice().to_vec())
+//     }
+// }
+//
+// #[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]
+//     fn from(s: [u8; N]) -> Self {
+//         ByteString(s.as_slice().to_vec())
+//     }
+// }
+//
+// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
+// #[unstable(feature = "bstr", issue = "134915")]
+// impl<'a> From<&'a [u8]> for ByteString {
+//     #[inline]
+//     fn from(s: &'a [u8]) -> Self {
+//         ByteString(s.to_vec())
+//     }
+// }
+//
+// #[unstable(feature = "bstr", issue = "134915")]
+// impl From<Vec<u8>> for ByteString {
+//     #[inline]
+//     fn from(s: Vec<u8>) -> Self {
+//         ByteString(s)
+//     }
+// }
 
 #[unstable(feature = "bstr", issue = "134915")]
 impl From<ByteString> for Vec<u8> {
@@ -236,22 +223,24 @@ 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]
-    fn from(s: &'a str) -> Self {
-        ByteString(s.as_bytes().to_vec())
-    }
-}
-
-#[unstable(feature = "bstr", issue = "134915")]
-impl From<String> for ByteString {
-    #[inline]
-    fn from(s: String) -> Self {
-        ByteString(s.into_bytes())
-    }
-}
+// Omitted due to inference failures
+//
+// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
+// #[unstable(feature = "bstr", issue = "134915")]
+// impl<'a> From<&'a str> for ByteString {
+//     #[inline]
+//     fn from(s: &'a str) -> Self {
+//         ByteString(s.as_bytes().to_vec())
+//     }
+// }
+//
+// #[unstable(feature = "bstr", issue = "134915")]
+// impl From<String> for ByteString {
+//     #[inline]
+//     fn from(s: String) -> Self {
+//         ByteString(s.into_bytes())
+//     }
+// }
 
 #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
 #[unstable(feature = "bstr", issue = "134915")]
diff --git a/library/core/src/bstr.rs b/library/core/src/bstr.rs
index 11212761ead..9f20eb1a0e8 100644
--- a/library/core/src/bstr.rs
+++ b/library/core/src/bstr.rs
@@ -246,21 +246,23 @@ impl<'a> Default for &'a mut ByteStr {
     }
 }
 
-#[unstable(feature = "bstr", issue = "134915")]
-impl<'a, const N: usize> From<&'a [u8; N]> for &'a ByteStr {
-    #[inline]
-    fn from(s: &'a [u8; N]) -> Self {
-        ByteStr::from_bytes(s)
-    }
-}
-
-#[unstable(feature = "bstr", issue = "134915")]
-impl<'a> From<&'a [u8]> for &'a ByteStr {
-    #[inline]
-    fn from(s: &'a [u8]) -> Self {
-        ByteStr::from_bytes(s)
-    }
-}
+// Omitted due to inference failures
+//
+// #[unstable(feature = "bstr", issue = "134915")]
+// impl<'a, const N: usize> From<&'a [u8; N]> for &'a ByteStr {
+//     #[inline]
+//     fn from(s: &'a [u8; N]) -> Self {
+//         ByteStr::from_bytes(s)
+//     }
+// }
+//
+// #[unstable(feature = "bstr", issue = "134915")]
+// impl<'a> From<&'a [u8]> for &'a ByteStr {
+//     #[inline]
+//     fn from(s: &'a [u8]) -> Self {
+//         ByteStr::from_bytes(s)
+//     }
+// }
 
 // Omitted due to slice-from-array-issue-113238:
 //
@@ -280,13 +282,15 @@ impl<'a> From<&'a [u8]> for &'a ByteStr {
 //     }
 // }
 
-#[unstable(feature = "bstr", issue = "134915")]
-impl<'a> From<&'a str> for &'a ByteStr {
-    #[inline]
-    fn from(s: &'a str) -> Self {
-        ByteStr::from_bytes(s.as_bytes())
-    }
-}
+// Omitted due to inference failures
+//
+// #[unstable(feature = "bstr", issue = "134915")]
+// impl<'a> From<&'a str> for &'a ByteStr {
+//     #[inline]
+//     fn from(s: &'a str) -> Self {
+//         ByteStr::from_bytes(s.as_bytes())
+//     }
+// }
 
 #[unstable(feature = "bstr", issue = "134915")]
 impl hash::Hash for ByteStr {