Skip to content

Commit 8bf943d

Browse files
Hopefully fixed an impl conflict for ToString for String (itself) vs. ToString for Display + ?Sized.
1 parent 7d05058 commit 8bf943d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

library/alloc/src/string.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,9 @@ where
21952195

21962196
#[cfg(not(no_global_oom_handling))]
21972197
#[stable(feature = "box_str2", since = "1.45.0")]
2198-
impl Extend<Box<str>> for String {
2198+
impl<const COOP_PREFERRED: bool> Extend<Box<str>> for String<COOP_PREFERRED>
2199+
where [(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
2200+
{
21992201
fn extend<I: IntoIterator<Item = Box<str>>>(&mut self, iter: I) {
22002202
iter.into_iter().for_each(move |s| self.push_str(&s));
22012203
}
@@ -2782,7 +2784,10 @@ where
27822784

27832785
#[cfg(not(no_global_oom_handling))]
27842786
#[stable(feature = "string_to_string_specialization", since = "1.17.0")]
2785-
impl<const COOP_PREFERRED: bool> ToString<COOP_PREFERRED> for String<COOP_PREFERRED> {
2787+
impl<const COOP_PREFERRED: bool> ToString<COOP_PREFERRED> for String<COOP_PREFERRED>
2788+
where
2789+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
2790+
{
27862791
#[inline]
27872792
fn to_string(&self) -> String<COOP_PREFERRED> {
27882793
self.to_owned()
@@ -2870,7 +2875,9 @@ where
28702875
// note: test pulls in std, which causes errors here
28712876
#[cfg(not(test))]
28722877
#[stable(feature = "string_from_box", since = "1.18.0")]
2873-
impl From<Box<str>> for String {
2878+
impl<const COOP_PREFERRED: bool> From<Box<str>> for String<COOP_PREFERRED>
2879+
where [(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
2880+
{
28742881
/// Converts the given boxed `str` slice to a [`String`].
28752882
/// It is notable that the `str` slice is owned.
28762883
///

0 commit comments

Comments
 (0)