Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/alloc/src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ macro_rules! specialize_for_lengths {
$num => {
for s in iter {
copy_slice_and_advance!(target, sep_bytes);
let content_bytes = s.borrow().as_ref();
let content_bytes: &[_] = s.borrow().as_ref();
copy_slice_and_advance!(target, content_bytes);
}
},
Expand All @@ -99,7 +99,7 @@ macro_rules! specialize_for_lengths {
// arbitrary non-zero size fallback
for s in iter {
copy_slice_and_advance!(target, sep_bytes);
let content_bytes = s.borrow().as_ref();
let content_bytes: &[_] = s.borrow().as_ref();
copy_slice_and_advance!(target, content_bytes);
}
}
Expand Down
8 changes: 7 additions & 1 deletion library/core/src/bstr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ impl AsRef<ByteStr> for ByteStr {
}
}

// `impl AsRef<ByteStr> for [u8]` omitted to avoid widespread inference failures
#[unstable(feature = "bstr", issue = "134915")]
impl AsRef<ByteStr> for [u8] {
#[inline]
fn as_ref(&self) -> &ByteStr {
ByteStr::new(self)
}
}

#[unstable(feature = "bstr", issue = "134915")]
impl AsRef<ByteStr> for str {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/useful_asref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait Trait {
fn as_ptr(&self);
}

impl<'a> Trait for &'a [u8] {
impl<'a> Trait for &'a [u32] {
fn as_ptr(&self) {
self.as_ref().as_ptr();
}
Expand Down
Loading