Skip to content

Commit 1f04b07

Browse files
Fixing A and COOP_PREFERRED generics. WIP...
1 parent ac054b9 commit 1f04b07

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

library/alloc/src/collections/vec_deque/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ where
166166
/// Creates an empty deque.
167167
#[inline]
168168
fn default() -> VecDeque<T, Global, COOP_PREFERRED> {
169-
VecDeque::new()
169+
VecDeque::<T, Global, COOP_PREFERRED>::new()
170170
}
171171
}
172172

@@ -554,6 +554,7 @@ where
554554
impl<T, A: Allocator, const COOP_PREFERRED: bool> VecDeque<T, A, COOP_PREFERRED>
555555
where
556556
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
557+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
557558
{
558559
/// Creates an empty deque.
559560
///
@@ -587,8 +588,8 @@ where
587588
#[inline]
588589
#[stable(feature = "rust1", since = "1.0.0")]
589590
#[must_use]
590-
pub fn with_capacity(capacity: usize) -> VecDeque<T, A, COOP_PREFERRED> {
591-
Self::with_capacity_in(capacity, Global)
591+
pub fn with_capacity(capacity: usize) -> VecDeque<T, Global, COOP_PREFERRED> {
592+
VecDeque::<T, Global, COOP_PREFERRED>::with_capacity_in(capacity, Global)
592593
}
593594
}
594595

@@ -1402,7 +1403,7 @@ where
14021403
/// ```
14031404
#[inline]
14041405
#[stable(feature = "drain", since = "1.6.0")]
1405-
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T, A>
1406+
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T, A, COOP_PREFERRED>
14061407
where
14071408
R: RangeBounds<usize>,
14081409
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(SHORT_TERM_VEC_PREFERS_COOP!())]:,
@@ -2923,7 +2924,7 @@ where
29232924
fn from(other: Vec<T, A, OTHER_COOP_PREFERRED>) -> Self
29242925
{
29252926
let (ptr, len, cap, alloc) = other.into_raw_parts_with_alloc();
2926-
Self { head: 0, len, buf: unsafe { RawVec::from_raw_parts_in(ptr, cap, alloc) } }
2927+
Self { head: 0, len, buf: unsafe { RawVec::<T, A, COOP_PREFERRED>::from_raw_parts_in(ptr, cap, alloc) } }
29272928
}
29282929
}
29292930

@@ -2982,7 +2983,7 @@ where
29822983
ptr::copy(buf.add(other.head), buf, len);
29832984
}
29842985
// @FIXME: COOP
2985-
Vec::from_raw_parts_in(buf, len, cap, alloc)
2986+
Vec::<T, A, COOP_PREFERRED>::from_raw_parts_in(buf, len, cap, alloc)
29862987
}
29872988
}
29882989
}
@@ -3003,7 +3004,7 @@ where
30033004
/// assert_eq!(deq1, deq2);
30043005
/// ```
30053006
fn from(arr: [T; N]) -> Self {
3006-
let mut deq = VecDeque::with_capacity(N);
3007+
let mut deq = VecDeque::<T, Global, COOP_PREFERRED>::with_capacity(N);
30073008
let arr = ManuallyDrop::new(arr);
30083009
if !<T>::IS_ZST {
30093010
// SAFETY: VecDeque::with_capacity ensures that there is enough capacity.

library/alloc/src/collections/vec_deque/spec_from_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ where
3939
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
4040
{
4141
#[inline]
42-
fn spec_from_iter(iterator: IntoIter<T>) -> Self {
42+
fn spec_from_iter(iterator: IntoIter<T, A, COOP_PREFERRED>) -> Self {
4343
iterator.into_vecdeque()
4444
}
4545
}

library/alloc/src/ffi/c_str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,8 @@ impl CStr {
11031103
without modifying the original"]
11041104
#[stable(feature = "cstr_to_str", since = "1.4.0")]
11051105
pub fn to_string_lossy(&self) -> Cow<'_, str> {
1106-
String::from_utf8_lossy(self.to_bytes())
1106+
// false = no need for co-alloc metadata, since it would get lost once converted to the slice.
1107+
String::<false>::from_utf8_lossy(self.to_bytes())
11071108
}
11081109

11091110
/// Converts a <code>[Box]<[CStr]></code> into a [`CString`] without copying or allocating.

0 commit comments

Comments
 (0)