diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2020-04-19 12:34:00 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2020-04-26 16:27:13 +0100 |
| commit | cb2703945ca3c6c9664a5a9ec606430cb79ba2c8 (patch) | |
| tree | f3779f0c94126d9d406a0e59e8d7eb0d9ef0b763 /src/liballoc/vec.rs | |
| parent | ec1f28f9614292c36b371d3758afffdd52cb9786 (diff) | |
| download | rust-cb2703945ca3c6c9664a5a9ec606430cb79ba2c8.tar.gz rust-cb2703945ca3c6c9664a5a9ec606430cb79ba2c8.zip | |
Use min_specialization in liballoc
- Remove a type parameter from `[A]RcFromIter`. - Remove an implementation of `[A]RcFromIter` that didn't actually specialize anything. - Remove unused implementation of `IsZero` for `Option<&mut T>`. - Change specializations of `[A]RcEqIdent` to use a marker trait version of `Eq`. - Remove `BTreeClone`. I couldn't find a way to make this work with `min_specialization`. - Add `rustc_unsafe_specialization_marker` to `Copy` and `TrustedLen`.
Diffstat (limited to 'src/liballoc/vec.rs')
| -rw-r--r-- | src/liballoc/vec.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index b4a9da84787..624ca2820d7 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1619,8 +1619,8 @@ impl<T: Default> Vec<T> { #[unstable(feature = "vec_resize_default", issue = "41758")] #[rustc_deprecated( reason = "This is moving towards being removed in favor \ - of `.resize_with(Default::default)`. If you disagree, please comment \ - in the tracking issue.", + of `.resize_with(Default::default)`. If you disagree, please comment \ + in the tracking issue.", since = "1.33.0" )] pub fn resize_default(&mut self, new_len: usize) { @@ -1825,6 +1825,7 @@ impl<T: Clone + IsZero> SpecFromElem for T { } } +#[rustc_specialization_trait] unsafe trait IsZero { /// Whether this value is zero fn is_zero(&self) -> bool; @@ -1874,9 +1875,12 @@ unsafe impl<T> IsZero for *mut T { } } -// `Option<&T>`, `Option<&mut T>` and `Option<Box<T>>` are guaranteed to represent `None` as null. -// For fat pointers, the bytes that would be the pointer metadata in the `Some` variant -// are padding in the `None` variant, so ignoring them and zero-initializing instead is ok. +// `Option<&T>` and `Option<Box<T>>` are guaranteed to represent `None` as null. +// For fat pointers, the bytes that would be the pointer metadata in the `Some` +// variant are padding in the `None` variant, so ignoring them and +// zero-initializing instead is ok. +// `Option<&mut T>` never implements `Clone`, so there's no need for an impl of +// `SpecFromElem`. unsafe impl<T: ?Sized> IsZero for Option<&T> { #[inline] @@ -1885,13 +1889,6 @@ unsafe impl<T: ?Sized> IsZero for Option<&T> { } } -unsafe impl<T: ?Sized> IsZero for Option<&mut T> { - #[inline] - fn is_zero(&self) -> bool { - self.is_none() - } -} - unsafe impl<T: ?Sized> IsZero for Option<Box<T>> { #[inline] fn is_zero(&self) -> bool { |
