Skip to content

Commit 24951f7

Browse files
joshtriplettgitbot
authored and
gitbot
committed
Omit some more From impls to avoid inference failures
1 parent 99da8ef commit 24951f7

File tree

2 files changed

+80
-87
lines changed

2 files changed

+80
-87
lines changed

Diff for: alloc/src/bstr.rs

+54-65
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,6 @@ use crate::vec::Vec;
4343
///
4444
/// The `Debug` and `Display` implementations for `ByteString` are the same as those for `ByteStr`,
4545
/// showing invalid UTF-8 as hex escapes or the Unicode replacement character, respectively.
46-
///
47-
/// # Examples
48-
///
49-
/// You can create a new `ByteString` from a `Vec<u8>` directly, or via a `From` impl from various
50-
/// string types:
51-
///
52-
/// ```
53-
/// # #![feature(bstr)]
54-
/// # use std::bstr::ByteString;
55-
/// let s1 = ByteString(vec![b'H', b'e', b'l', b'l', b'o']);
56-
/// let s2 = ByteString::from("Hello");
57-
/// let s3 = ByteString::from(b"Hello");
58-
/// assert_eq!(s1, s2);
59-
/// assert_eq!(s2, s3);
60-
/// ```
6146
#[unstable(feature = "bstr", issue = "134915")]
6247
#[repr(transparent)]
6348
#[derive(Clone)]
@@ -193,40 +178,42 @@ impl Default for ByteString {
193178
}
194179
}
195180

196-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
197-
#[unstable(feature = "bstr", issue = "134915")]
198-
impl<'a, const N: usize> From<&'a [u8; N]> for ByteString {
199-
#[inline]
200-
fn from(s: &'a [u8; N]) -> Self {
201-
ByteString(s.as_slice().to_vec())
202-
}
203-
}
204-
205-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
206-
#[unstable(feature = "bstr", issue = "134915")]
207-
impl<const N: usize> From<[u8; N]> for ByteString {
208-
#[inline]
209-
fn from(s: [u8; N]) -> Self {
210-
ByteString(s.as_slice().to_vec())
211-
}
212-
}
213-
214-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
215-
#[unstable(feature = "bstr", issue = "134915")]
216-
impl<'a> From<&'a [u8]> for ByteString {
217-
#[inline]
218-
fn from(s: &'a [u8]) -> Self {
219-
ByteString(s.to_vec())
220-
}
221-
}
222-
223-
#[unstable(feature = "bstr", issue = "134915")]
224-
impl From<Vec<u8>> for ByteString {
225-
#[inline]
226-
fn from(s: Vec<u8>) -> Self {
227-
ByteString(s)
228-
}
229-
}
181+
// Omitted due to inference failures
182+
//
183+
// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
184+
// #[unstable(feature = "bstr", issue = "134915")]
185+
// impl<'a, const N: usize> From<&'a [u8; N]> for ByteString {
186+
// #[inline]
187+
// fn from(s: &'a [u8; N]) -> Self {
188+
// ByteString(s.as_slice().to_vec())
189+
// }
190+
// }
191+
//
192+
// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
193+
// #[unstable(feature = "bstr", issue = "134915")]
194+
// impl<const N: usize> From<[u8; N]> for ByteString {
195+
// #[inline]
196+
// fn from(s: [u8; N]) -> Self {
197+
// ByteString(s.as_slice().to_vec())
198+
// }
199+
// }
200+
//
201+
// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
202+
// #[unstable(feature = "bstr", issue = "134915")]
203+
// impl<'a> From<&'a [u8]> for ByteString {
204+
// #[inline]
205+
// fn from(s: &'a [u8]) -> Self {
206+
// ByteString(s.to_vec())
207+
// }
208+
// }
209+
//
210+
// #[unstable(feature = "bstr", issue = "134915")]
211+
// impl From<Vec<u8>> for ByteString {
212+
// #[inline]
213+
// fn from(s: Vec<u8>) -> Self {
214+
// ByteString(s)
215+
// }
216+
// }
230217

231218
#[unstable(feature = "bstr", issue = "134915")]
232219
impl From<ByteString> for Vec<u8> {
@@ -236,22 +223,24 @@ impl From<ByteString> for Vec<u8> {
236223
}
237224
}
238225

239-
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
240-
#[unstable(feature = "bstr", issue = "134915")]
241-
impl<'a> From<&'a str> for ByteString {
242-
#[inline]
243-
fn from(s: &'a str) -> Self {
244-
ByteString(s.as_bytes().to_vec())
245-
}
246-
}
247-
248-
#[unstable(feature = "bstr", issue = "134915")]
249-
impl From<String> for ByteString {
250-
#[inline]
251-
fn from(s: String) -> Self {
252-
ByteString(s.into_bytes())
253-
}
254-
}
226+
// Omitted due to inference failures
227+
//
228+
// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
229+
// #[unstable(feature = "bstr", issue = "134915")]
230+
// impl<'a> From<&'a str> for ByteString {
231+
// #[inline]
232+
// fn from(s: &'a str) -> Self {
233+
// ByteString(s.as_bytes().to_vec())
234+
// }
235+
// }
236+
//
237+
// #[unstable(feature = "bstr", issue = "134915")]
238+
// impl From<String> for ByteString {
239+
// #[inline]
240+
// fn from(s: String) -> Self {
241+
// ByteString(s.into_bytes())
242+
// }
243+
// }
255244

256245
#[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
257246
#[unstable(feature = "bstr", issue = "134915")]

Diff for: core/src/bstr.rs

+26-22
Original file line numberDiff line numberDiff line change
@@ -246,21 +246,23 @@ impl<'a> Default for &'a mut ByteStr {
246246
}
247247
}
248248

249-
#[unstable(feature = "bstr", issue = "134915")]
250-
impl<'a, const N: usize> From<&'a [u8; N]> for &'a ByteStr {
251-
#[inline]
252-
fn from(s: &'a [u8; N]) -> Self {
253-
ByteStr::from_bytes(s)
254-
}
255-
}
256-
257-
#[unstable(feature = "bstr", issue = "134915")]
258-
impl<'a> From<&'a [u8]> for &'a ByteStr {
259-
#[inline]
260-
fn from(s: &'a [u8]) -> Self {
261-
ByteStr::from_bytes(s)
262-
}
263-
}
249+
// Omitted due to inference failures
250+
//
251+
// #[unstable(feature = "bstr", issue = "134915")]
252+
// impl<'a, const N: usize> From<&'a [u8; N]> for &'a ByteStr {
253+
// #[inline]
254+
// fn from(s: &'a [u8; N]) -> Self {
255+
// ByteStr::from_bytes(s)
256+
// }
257+
// }
258+
//
259+
// #[unstable(feature = "bstr", issue = "134915")]
260+
// impl<'a> From<&'a [u8]> for &'a ByteStr {
261+
// #[inline]
262+
// fn from(s: &'a [u8]) -> Self {
263+
// ByteStr::from_bytes(s)
264+
// }
265+
// }
264266

265267
// Omitted due to slice-from-array-issue-113238:
266268
//
@@ -280,13 +282,15 @@ impl<'a> From<&'a [u8]> for &'a ByteStr {
280282
// }
281283
// }
282284

283-
#[unstable(feature = "bstr", issue = "134915")]
284-
impl<'a> From<&'a str> for &'a ByteStr {
285-
#[inline]
286-
fn from(s: &'a str) -> Self {
287-
ByteStr::from_bytes(s.as_bytes())
288-
}
289-
}
285+
// Omitted due to inference failures
286+
//
287+
// #[unstable(feature = "bstr", issue = "134915")]
288+
// impl<'a> From<&'a str> for &'a ByteStr {
289+
// #[inline]
290+
// fn from(s: &'a str) -> Self {
291+
// ByteStr::from_bytes(s.as_bytes())
292+
// }
293+
// }
290294

291295
#[unstable(feature = "bstr", issue = "134915")]
292296
impl hash::Hash for ByteStr {

0 commit comments

Comments
 (0)