diff options
| author | bors <bors@rust-lang.org> | 2019-07-28 09:12:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-07-28 09:12:04 +0000 |
| commit | 0cfb2f7fbda1d27e12913d21d1c8e56a4133dbe1 (patch) | |
| tree | 5f511147f1c0f419f26fb362c24710e1cd459ec6 /src/liballoc | |
| parent | 9a239ef4ded03d155c72b68b5a2dd7aff013e141 (diff) | |
| parent | 370aa19f28ea6d42f1aaf6de39a294e5e4e9aab7 (diff) | |
| download | rust-0cfb2f7fbda1d27e12913d21d1c8e56a4133dbe1.tar.gz rust-0cfb2f7fbda1d27e12913d21d1c8e56a4133dbe1.zip | |
Auto merge of #63074 - Centril:rollup-k1a8z0n, r=Centril
Rollup of 8 pull requests Successful merges: - #62550 (Implement RFC 2707 + Parser recovery for range patterns) - #62759 (Actually add rustc-guide to toolstate, don't fail builds for the guide) - #62806 (Fix few Clippy warnings) - #62974 (bump crossbeam-epoch dependency) - #63051 (Avoid ICE when referencing desugared local binding in borrow error) - #63061 (In which we constantly improve the Vec(Deque) array PartialEq impls) - #63067 (Add test for issue-50900) - #63071 (Allow rustbot to add `F-*` + `requires-nightly`.) Failed merges: r? @ghost
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/collections/btree/map.rs | 6 | ||||
| -rw-r--r-- | src/liballoc/collections/linked_list.rs | 8 | ||||
| -rw-r--r-- | src/liballoc/collections/vec_deque.rs | 40 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/vec.rs | 56 |
7 files changed, 48 insertions, 68 deletions
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 7cf779b3e72..1683b810556 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -200,7 +200,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> { } } - if self.len() == 0 { + if self.is_empty() { // Ideally we'd call `BTreeMap::new` here, but that has the `K: // Ord` constraint, which this method lacks. BTreeMap { @@ -759,12 +759,12 @@ impl<K: Ord, V> BTreeMap<K, V> { #[stable(feature = "btree_append", since = "1.11.0")] pub fn append(&mut self, other: &mut Self) { // Do we have to append anything at all? - if other.len() == 0 { + if other.is_empty() { return; } // We can just swap `self` and `other` if `self` is empty. - if self.len() == 0 { + if self.is_empty() { mem::swap(self, other); return; } diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index db0d6e2f9b9..bbb96725ea0 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -237,15 +237,15 @@ impl<T> LinkedList<T> { // Not creating new mutable (unique!) references overlapping `element`. match node.prev { - Some(prev) => (*prev.as_ptr()).next = node.next.clone(), + Some(prev) => (*prev.as_ptr()).next = node.next, // this node is the head node - None => self.head = node.next.clone(), + None => self.head = node.next, }; match node.next { - Some(next) => (*next.as_ptr()).prev = node.prev.clone(), + Some(next) => (*next.as_ptr()).prev = node.prev, // this node is the tail node - None => self.tail = node.prev.clone(), + None => self.tail = node.prev, }; self.len -= 1; diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index d149f742b01..495165f7786 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -9,6 +9,7 @@ #![stable(feature = "rust1", since = "1.0.0")] +use core::array::LengthAtMost32; use core::cmp::{self, Ordering}; use core::fmt; use core::iter::{repeat_with, FromIterator, FusedIterator}; @@ -2571,13 +2572,14 @@ impl<A: PartialEq> PartialEq for VecDeque<A> { impl<A: Eq> Eq for VecDeque<A> {} macro_rules! __impl_slice_eq1 { - ($Lhs: ty, $Rhs: ty) => { - __impl_slice_eq1! { $Lhs, $Rhs, Sized } - }; - ($Lhs: ty, $Rhs: ty, $Bound: ident) => { + ([$($vars:tt)*] $lhs:ty, $rhs:ty, $($constraints:tt)*) => { #[stable(feature = "vec_deque_partial_eq_slice", since = "1.17.0")] - impl<A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> { - fn eq(&self, other: &$Rhs) -> bool { + impl<A, B, $($vars)*> PartialEq<$rhs> for $lhs + where + A: PartialEq<B>, + $($constraints)* + { + fn eq(&self, other: &$rhs) -> bool { if self.len() != other.len() { return false; } @@ -2589,26 +2591,12 @@ macro_rules! __impl_slice_eq1 { } } -__impl_slice_eq1! { VecDeque<A>, Vec<B> } -__impl_slice_eq1! { VecDeque<A>, &[B] } -__impl_slice_eq1! { VecDeque<A>, &mut [B] } - -macro_rules! array_impls { - ($($N: expr)+) => { - $( - __impl_slice_eq1! { VecDeque<A>, [B; $N] } - __impl_slice_eq1! { VecDeque<A>, &[B; $N] } - __impl_slice_eq1! { VecDeque<A>, &mut [B; $N] } - )+ - } -} - -array_impls! { - 0 1 2 3 4 5 6 7 8 9 - 10 11 12 13 14 15 16 17 18 19 - 20 21 22 23 24 25 26 27 28 29 - 30 31 32 -} +__impl_slice_eq1! { [] VecDeque<A>, Vec<B>, } +__impl_slice_eq1! { [] VecDeque<A>, &[B], } +__impl_slice_eq1! { [] VecDeque<A>, &mut [B], } +__impl_slice_eq1! { [const N: usize] VecDeque<A>, [B; N], [B; N]: LengthAtMost32 } +__impl_slice_eq1! { [const N: usize] VecDeque<A>, &[B; N], [B; N]: LengthAtMost32 } +__impl_slice_eq1! { [const N: usize] VecDeque<A>, &mut [B; N], [B; N]: LengthAtMost32 } #[stable(feature = "rust1", since = "1.0.0")] impl<A: PartialOrd> PartialOrd for VecDeque<A> { diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index dbc1f3b47c8..e42d6434725 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -78,6 +78,8 @@ #![feature(cfg_target_has_atomic)] #![feature(coerce_unsized)] #![cfg_attr(not(bootstrap), feature(const_in_array_repeat_expressions))] +#![feature(const_generic_impls_guard)] +#![feature(const_generics)] #![feature(dispatch_from_dyn)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 36d54656795..0d0ff7c16f1 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -815,7 +815,7 @@ impl<T> Rc<[T]> { let slice = from_raw_parts_mut(self.elems, self.n_elems); ptr::drop_in_place(slice); - Global.dealloc(self.mem, self.layout.clone()); + Global.dealloc(self.mem, self.layout); } } } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 7cb826ee024..93aff733724 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -703,7 +703,7 @@ impl<T> Arc<[T]> { let slice = from_raw_parts_mut(self.elems, self.n_elems); ptr::drop_in_place(slice); - Global.dealloc(self.mem.cast(), self.layout.clone()); + Global.dealloc(self.mem.cast(), self.layout); } } } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index c076584cc38..dac04e4e624 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -56,6 +56,7 @@ #![stable(feature = "rust1", since = "1.0.0")] +use core::array::LengthAtMost32; use core::cmp::{self, Ordering}; use core::fmt; use core::hash::{self, Hash}; @@ -2171,47 +2172,36 @@ impl<'a, T: 'a + Copy> Extend<&'a T> for Vec<T> { } macro_rules! __impl_slice_eq1 { - ($Lhs: ty, $Rhs: ty) => { - __impl_slice_eq1! { $Lhs, $Rhs, Sized } - }; - ($Lhs: ty, $Rhs: ty, $Bound: ident) => { + ([$($vars:tt)*] $lhs:ty, $rhs:ty, $($constraints:tt)*) => { #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> { + impl<A, B, $($vars)*> PartialEq<$rhs> for $lhs + where + A: PartialEq<B>, + $($constraints)* + { #[inline] - fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] } + fn eq(&self, other: &$rhs) -> bool { self[..] == other[..] } #[inline] - fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] } + fn ne(&self, other: &$rhs) -> bool { self[..] != other[..] } } } } -__impl_slice_eq1! { Vec<A>, Vec<B> } -__impl_slice_eq1! { Vec<A>, &'b [B] } -__impl_slice_eq1! { Vec<A>, &'b mut [B] } -__impl_slice_eq1! { Cow<'a, [A]>, &'b [B], Clone } -__impl_slice_eq1! { Cow<'a, [A]>, &'b mut [B], Clone } -__impl_slice_eq1! { Cow<'a, [A]>, Vec<B>, Clone } +__impl_slice_eq1! { [] Vec<A>, Vec<B>, } +__impl_slice_eq1! { [] Vec<A>, &[B], } +__impl_slice_eq1! { [] Vec<A>, &mut [B], } +__impl_slice_eq1! { [] Cow<'_, [A]>, &[B], A: Clone } +__impl_slice_eq1! { [] Cow<'_, [A]>, &mut [B], A: Clone } +__impl_slice_eq1! { [] Cow<'_, [A]>, Vec<B>, A: Clone } +__impl_slice_eq1! { [const N: usize] Vec<A>, [B; N], [B; N]: LengthAtMost32 } +__impl_slice_eq1! { [const N: usize] Vec<A>, &[B; N], [B; N]: LengthAtMost32 } -macro_rules! array_impls { - ($($N: expr)+) => { - $( - // NOTE: some less important impls are omitted to reduce code bloat - __impl_slice_eq1! { Vec<A>, [B; $N] } - __impl_slice_eq1! { Vec<A>, &'b [B; $N] } - // __impl_slice_eq1! { Vec<A>, &'b mut [B; $N] } - // __impl_slice_eq1! { Cow<'a, [A]>, [B; $N], Clone } - // __impl_slice_eq1! { Cow<'a, [A]>, &'b [B; $N], Clone } - // __impl_slice_eq1! { Cow<'a, [A]>, &'b mut [B; $N], Clone } - )+ - } -} - -array_impls! { - 0 1 2 3 4 5 6 7 8 9 - 10 11 12 13 14 15 16 17 18 19 - 20 21 22 23 24 25 26 27 28 29 - 30 31 32 -} +// NOTE: some less important impls are omitted to reduce code bloat +// FIXME(Centril): Reconsider this? +//__impl_slice_eq1! { [const N: usize] Vec<A>, &mut [B; N], [B; N]: LengthAtMost32 } +//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, [B; N], [B; N]: LengthAtMost32 } +//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &[B; N], [B; N]: LengthAtMost32 } +//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &mut [B; N], [B; N]: LengthAtMost32 } /// Implements comparison of vectors, lexicographically. #[stable(feature = "rust1", since = "1.0.0")] |
