Skip to content

Commit

Permalink
CoAlloc: Vec: Working around ICE rust-lang/rust issue rust-lang#106473
Browse files Browse the repository at this point in the history
…ICE. WIP
  • Loading branch information
peter-lyons-kehl committed Feb 20, 2023
1 parent e1d529e commit 30f2fdb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion library/alloc/src/vec/in_place_collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub(super) trait InPlaceIterableMarker {}

impl<T> InPlaceIterableMarker for T where T: InPlaceIterable {}

impl<T, I> SpecFromIter<T, I> for Vec<T>
impl<T, I> SpecFromIter<T, I> for Vec<T, Global, DEFAULT_COOP_PREFERRED>
where
I: Iterator<Item = T> + SourceIter<Source: AsVecIntoIter> + InPlaceIterableMarker,
{
Expand Down
12 changes: 6 additions & 6 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2845,7 +2845,7 @@ where

#[cfg(not(no_global_oom_handling))]
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> FromIterator<T> for Vec<T> {
impl<T> FromIterator<T> for Vec<T, Global, DEFAULT_COOP_PREFERRED> {
#[inline]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Vec<T> {
<Self as SpecFromIter<T, I::IntoIter>>::from_iter(iter.into_iter())
Expand Down Expand Up @@ -3263,7 +3263,7 @@ where

#[cfg(not(no_global_oom_handling))]
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Clone> From<&[T]> for Vec<T> {
impl<T: Clone> From<&[T]> for Vec<T, Global, DEFAULT_COOP_PREFERRED> {
/// Allocate a `Vec<T>` and fill it by cloning `s`'s items.
///
/// # Examples
Expand All @@ -3283,7 +3283,7 @@ impl<T: Clone> From<&[T]> for Vec<T> {

#[cfg(not(no_global_oom_handling))]
#[stable(feature = "vec_from_mut", since = "1.19.0")]
impl<T: Clone> From<&mut [T]> for Vec<T> {
impl<T: Clone> From<&mut [T]> for Vec<T, Global, DEFAULT_COOP_PREFERRED> {
/// Allocate a `Vec<T>` and fill it by cloning `s`'s items.
///
/// # Examples
Expand All @@ -3303,7 +3303,7 @@ impl<T: Clone> From<&mut [T]> for Vec<T> {

#[cfg(not(no_global_oom_handling))]
#[stable(feature = "vec_from_array", since = "1.44.0")]
impl<T, const N: usize> From<[T; N]> for Vec<T> {
impl<T, const N: usize> From<[T; N]> for Vec<T, Global, DEFAULT_COOP_PREFERRED> {
/// Allocate a `Vec<T>` and move `s`'s items into it.
///
/// # Examples
Expand All @@ -3326,7 +3326,7 @@ impl<T, const N: usize> From<[T; N]> for Vec<T> {
}

#[stable(feature = "vec_from_cow_slice", since = "1.14.0")]
impl<'a, T> From<Cow<'a, [T]>> for Vec<T>
impl<'a, T> From<Cow<'a, [T]>> for Vec<T, Global, DEFAULT_COOP_PREFERRED>
where
[T]: ToOwned<Owned = Vec<T>>,
{
Expand Down Expand Up @@ -3403,7 +3403,7 @@ where

#[cfg(not(no_global_oom_handling))]
#[stable(feature = "rust1", since = "1.0.0")]
impl From<&str> for Vec<u8> {
impl From<&str> for Vec<u8, Global, DEFAULT_COOP_PREFERRED> {
/// Allocate a `Vec<u8>` and fill it with a UTF-8 string.
///
/// # Examples
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/vec/spec_from_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(super) trait SpecFromIter<T, I> {
fn from_iter(iter: I) -> Self;
}

impl<T, I> SpecFromIter<T, I> for Vec<T>
impl<T, I> SpecFromIter<T, I> for Vec<T, Global, DEFAULT_COOP_PREFERRED>
where
I: Iterator<Item = T>,
{
Expand All @@ -34,7 +34,7 @@ where
}
}

impl<T> SpecFromIter<T, IntoIter<T>> for Vec<T> {
impl<T> SpecFromIter<T, IntoIter<T>> for Vec<T, Global, DEFAULT_COOP_PREFERRED> {
fn from_iter(iterator: IntoIter<T>) -> Self {
// A common case is passing a vector into a function which immediately
// re-collects into a vector. We can short circuit this if the IntoIter
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/vec/spec_from_iter_nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(super) trait SpecFromIterNested<T, I> {
fn from_iter(iter: I) -> Self;
}

impl<T, I> SpecFromIterNested<T, I> for Vec<T>
impl<T, I> SpecFromIterNested<T, I> for Vec<T, Global, DEFAULT_COOP_PREFERRED>
where
I: Iterator<Item = T>,
{
Expand Down Expand Up @@ -45,7 +45,7 @@ where
}
}

impl<T, I> SpecFromIterNested<T, I> for Vec<T>
impl<T, I> SpecFromIterNested<T, I> for Vec<T, Global, DEFAULT_COOP_PREFERRED>
where
I: TrustedLen<Item = T>,
{
Expand Down
4 changes: 2 additions & 2 deletions library/proc_macro/src/bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ impl<'a, T, M> Unmark for &'a mut Marked<T, M> {
}
}

impl<T: Mark> Mark for Vec<T> {
impl<T: Mark> Mark for Vec<T, Global, DEFAULT_COOP_PREFERRED> {
type Unmarked = Vec<T::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
// Should be a no-op due to std's in-place collect optimizations.
unmarked.into_iter().map(T::mark).collect()
}
}
impl<T: Unmark> Unmark for Vec<T> {
impl<T: Unmark> Unmark for Vec<T, Global, DEFAULT_COOP_PREFERRED> {
type Unmarked = Vec<T::Unmarked>;
fn unmark(self) -> Self::Unmarked {
// Should be a no-op due to std's in-place collect optimizations.
Expand Down
4 changes: 2 additions & 2 deletions library/proc_macro/src/bridge/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl<S> DecodeMut<'_, '_, S> for String {
}
}

impl<S, T: Encode<S>> Encode<S> for Vec<T> {
impl<S, T: Encode<S>> Encode<S> for Vec<T, Global, DEFAULT_COOP_PREFERRED> {
fn encode(self, w: &mut Writer, s: &mut S) {
self.len().encode(w, s);
for x in self {
Expand All @@ -233,7 +233,7 @@ impl<S, T: Encode<S>> Encode<S> for Vec<T> {
}
}

impl<'a, S, T: for<'s> DecodeMut<'a, 's, S>> DecodeMut<'a, '_, S> for Vec<T> {
impl<'a, S, T: for<'s> DecodeMut<'a, 's, S>> DecodeMut<'a, '_, S> for Vec<T, Global, DEFAULT_COOP_PREFERRED> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
let len = usize::decode(r, s);
let mut vec = Vec::with_capacity(len);
Expand Down
2 changes: 1 addition & 1 deletion library/proc_macro/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl MultiSpan for Span {
}

#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
impl MultiSpan for Vec<Span> {
impl MultiSpan for Vec<Span, Global, DEFAULT_COOP_PREFERRED> {
fn into_spans(self) -> Vec<Span> {
self
}
Expand Down

0 comments on commit 30f2fdb

Please sign in to comment.