Skip to content

Commit d6a65cd

Browse files
committed
Auto merge of #27975 - sfackler:iter-order-methods, r=aturon
This does cause some breakage due to deficiencies in resolve - `path::Components` is both an `Iterator` and implements `Eq`, `Ord`, etc. If one calls e.g. `partial_cmp` on a `Components` and passes a `&Components` intending to target the `PartialOrd` impl, the compiler will select the `partial_cmp` from `Iterator` and then error out. I doubt anyone will run into breakage from `Components` specifically, but we should see if there are third party types that will run into issues. `iter::order::equals` wasn't moved to `Iterator` since it's exactly the same as `iter::order::eq` but with an `Eq` instead of `PartialEq` bound, which doensn't seem very useful. I also updated `le`, `gt`, etc to use `partial_cmp` which lets us drop the extra `PartialEq` bound. cc #27737 r? @alexcrichton
2 parents 0d5142f + 651c42f commit d6a65cd

File tree

7 files changed

+238
-115
lines changed

7 files changed

+238
-115
lines changed

src/libcollections/btree/map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use core::fmt::Debug;
2222
use core::hash::{Hash, Hasher};
2323
use core::iter::{Map, FromIterator};
2424
use core::ops::Index;
25-
use core::{iter, fmt, mem, usize};
25+
use core::{fmt, mem, usize};
2626
use Bound::{self, Included, Excluded, Unbounded};
2727

2828
use borrow::Borrow;
@@ -915,15 +915,15 @@ impl<K: Eq, V: Eq> Eq for BTreeMap<K, V> {}
915915
impl<K: PartialOrd, V: PartialOrd> PartialOrd for BTreeMap<K, V> {
916916
#[inline]
917917
fn partial_cmp(&self, other: &BTreeMap<K, V>) -> Option<Ordering> {
918-
iter::order::partial_cmp(self.iter(), other.iter())
918+
self.iter().partial_cmp(other.iter())
919919
}
920920
}
921921

922922
#[stable(feature = "rust1", since = "1.0.0")]
923923
impl<K: Ord, V: Ord> Ord for BTreeMap<K, V> {
924924
#[inline]
925925
fn cmp(&self, other: &BTreeMap<K, V>) -> Ordering {
926-
iter::order::cmp(self.iter(), other.iter())
926+
self.iter().cmp(other.iter())
927927
}
928928
}
929929

src/libcollections/linked_list.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use alloc::boxed::Box;
2525
use core::cmp::Ordering;
2626
use core::fmt;
2727
use core::hash::{Hasher, Hash};
28-
use core::iter::{self, FromIterator};
28+
use core::iter::FromIterator;
2929
use core::mem;
3030
use core::ptr;
3131

@@ -917,12 +917,12 @@ impl<'a, T: 'a + Copy> Extend<&'a T> for LinkedList<T> {
917917
impl<A: PartialEq> PartialEq for LinkedList<A> {
918918
fn eq(&self, other: &LinkedList<A>) -> bool {
919919
self.len() == other.len() &&
920-
iter::order::eq(self.iter(), other.iter())
920+
self.iter().eq(other.iter())
921921
}
922922

923923
fn ne(&self, other: &LinkedList<A>) -> bool {
924924
self.len() != other.len() ||
925-
iter::order::ne(self.iter(), other.iter())
925+
self.iter().ne(other.iter())
926926
}
927927
}
928928

@@ -932,15 +932,15 @@ impl<A: Eq> Eq for LinkedList<A> {}
932932
#[stable(feature = "rust1", since = "1.0.0")]
933933
impl<A: PartialOrd> PartialOrd for LinkedList<A> {
934934
fn partial_cmp(&self, other: &LinkedList<A>) -> Option<Ordering> {
935-
iter::order::partial_cmp(self.iter(), other.iter())
935+
self.iter().partial_cmp(other.iter())
936936
}
937937
}
938938

939939
#[stable(feature = "rust1", since = "1.0.0")]
940940
impl<A: Ord> Ord for LinkedList<A> {
941941
#[inline]
942942
fn cmp(&self, other: &LinkedList<A>) -> Ordering {
943-
iter::order::cmp(self.iter(), other.iter())
943+
self.iter().cmp(other.iter())
944944
}
945945
}
946946

src/libcollections/vec_deque.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
use core::cmp::Ordering;
2222
use core::fmt;
23-
use core::iter::{self, repeat, FromIterator};
23+
use core::iter::{repeat, FromIterator};
2424
use core::ops::{Index, IndexMut};
2525
use core::ptr;
2626
use core::slice;
@@ -1676,15 +1676,15 @@ impl<A: Eq> Eq for VecDeque<A> {}
16761676
#[stable(feature = "rust1", since = "1.0.0")]
16771677
impl<A: PartialOrd> PartialOrd for VecDeque<A> {
16781678
fn partial_cmp(&self, other: &VecDeque<A>) -> Option<Ordering> {
1679-
iter::order::partial_cmp(self.iter(), other.iter())
1679+
self.iter().partial_cmp(other.iter())
16801680
}
16811681
}
16821682

16831683
#[stable(feature = "rust1", since = "1.0.0")]
16841684
impl<A: Ord> Ord for VecDeque<A> {
16851685
#[inline]
16861686
fn cmp(&self, other: &VecDeque<A>) -> Ordering {
1687-
iter::order::cmp(self.iter(), other.iter())
1687+
self.iter().cmp(other.iter())
16881688
}
16891689
}
16901690

0 commit comments

Comments
 (0)