about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-03-19 09:01:17 +0100
committerManish Goregaokar <manishsmail@gmail.com>2018-03-29 13:12:49 +0200
commitc3a63970dee2422e2fcc79d8b99303b4b046f444 (patch)
treef8cdc9df5af3d6f06bac1650ac7df2bbe549b7f3
parent409744bcb91f4efa35b8fcc9e7033523a86b90c2 (diff)
downloadrust-c3a63970dee2422e2fcc79d8b99303b4b046f444.tar.gz
rust-c3a63970dee2422e2fcc79d8b99303b4b046f444.zip
Move alloc::Bound to {core,std}::ops
The stable reexport `std::collections::Bound` is now deprecated.

Another deprecated reexport could be added in `alloc`,
but that crate is unstable.
-rw-r--r--src/liballoc/btree/map.rs4
-rw-r--r--src/liballoc/btree/set.rs2
-rw-r--r--src/liballoc/lib.rs51
-rw-r--r--src/liballoc/range.rs2
-rw-r--r--src/liballoc/string.rs2
-rw-r--r--src/liballoc/tests/btree/map.rs2
-rw-r--r--src/liballoc/vec.rs2
-rw-r--r--src/liballoc/vec_deque.rs2
-rw-r--r--src/libcore/ops/mod.rs2
-rw-r--r--src/libcore/ops/range.rs51
-rw-r--r--src/librustc_data_structures/array_vec.rs2
-rw-r--r--src/libstd/collections/mod.rs3
-rw-r--r--src/test/run-pass/sync-send-iterators-in-libcollections.rs2
13 files changed, 64 insertions, 63 deletions
diff --git a/src/liballoc/btree/map.rs b/src/liballoc/btree/map.rs
index cada190032a..2ba56063e36 100644
--- a/src/liballoc/btree/map.rs
+++ b/src/liballoc/btree/map.rs
@@ -13,11 +13,11 @@ use core::fmt::Debug;
 use core::hash::{Hash, Hasher};
 use core::iter::{FromIterator, Peekable, FusedIterator};
 use core::marker::PhantomData;
+use core::ops::Bound::{Excluded, Included, Unbounded};
 use core::ops::Index;
 use core::{fmt, intrinsics, mem, ptr};
 
 use borrow::Borrow;
-use Bound::{Excluded, Included, Unbounded};
 use range::RangeArgument;
 
 use super::node::{self, Handle, NodeRef, marker};
@@ -804,7 +804,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
     ///
     /// ```
     /// use std::collections::BTreeMap;
-    /// use std::collections::Bound::Included;
+    /// use std::ops::Bound::Included;
     ///
     /// let mut map = BTreeMap::new();
     /// map.insert(3, "a");
diff --git a/src/liballoc/btree/set.rs b/src/liballoc/btree/set.rs
index 2e3157147a0..d488dd6cbbd 100644
--- a/src/liballoc/btree/set.rs
+++ b/src/liballoc/btree/set.rs
@@ -240,7 +240,7 @@ impl<T: Ord> BTreeSet<T> {
     ///
     /// ```
     /// use std::collections::BTreeSet;
-    /// use std::collections::Bound::Included;
+    /// use std::ops::Bound::Included;
     ///
     /// let mut set = BTreeSet::new();
     /// set.insert(3);
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 19d64d8fea9..eddbd50ea03 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -204,57 +204,6 @@ mod std {
     pub use core::ops;      // RangeFull
 }
 
-/// An endpoint of a range of keys.
-///
-/// # Examples
-///
-/// `Bound`s are range endpoints:
-///
-/// ```
-/// #![feature(collections_range)]
-///
-/// use std::collections::range::RangeArgument;
-/// use std::collections::Bound::*;
-///
-/// assert_eq!((..100).start(), Unbounded);
-/// assert_eq!((1..12).start(), Included(&1));
-/// assert_eq!((1..12).end(), Excluded(&12));
-/// ```
-///
-/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
-/// Note that in most cases, it's better to use range syntax (`1..5`) instead.
-///
-/// ```
-/// use std::collections::BTreeMap;
-/// use std::collections::Bound::{Excluded, Included, Unbounded};
-///
-/// let mut map = BTreeMap::new();
-/// map.insert(3, "a");
-/// map.insert(5, "b");
-/// map.insert(8, "c");
-///
-/// for (key, value) in map.range((Excluded(3), Included(8))) {
-///     println!("{}: {}", key, value);
-/// }
-///
-/// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
-/// ```
-///
-/// [`BTreeMap::range`]: btree_map/struct.BTreeMap.html#method.range
-#[stable(feature = "collections_bound", since = "1.17.0")]
-#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
-pub enum Bound<T> {
-    /// An inclusive bound.
-    #[stable(feature = "collections_bound", since = "1.17.0")]
-    Included(#[stable(feature = "collections_bound", since = "1.17.0")] T),
-    /// An exclusive bound.
-    #[stable(feature = "collections_bound", since = "1.17.0")]
-    Excluded(#[stable(feature = "collections_bound", since = "1.17.0")] T),
-    /// An infinite endpoint. Indicates that there is no bound in this direction.
-    #[stable(feature = "collections_bound", since = "1.17.0")]
-    Unbounded,
-}
-
 /// An intermediate trait for specialization of `Extend`.
 #[doc(hidden)]
 trait SpecExtend<I: IntoIterator> {
diff --git a/src/liballoc/range.rs b/src/liballoc/range.rs
index b03abc85180..7cadbf3c90a 100644
--- a/src/liballoc/range.rs
+++ b/src/liballoc/range.rs
@@ -15,7 +15,7 @@
 //! Range syntax.
 
 use core::ops::{RangeFull, Range, RangeTo, RangeFrom, RangeInclusive, RangeToInclusive};
-use Bound::{self, Excluded, Included, Unbounded};
+use core::ops::Bound::{self, Excluded, Included, Unbounded};
 
 /// `RangeArgument` is implemented by Rust's built-in range types, produced
 /// by range syntax like `..`, `a..`, `..b` or `c..d`.
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 23c12bef3aa..754c78f7779 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -59,6 +59,7 @@
 use core::fmt;
 use core::hash;
 use core::iter::{FromIterator, FusedIterator};
+use core::ops::Bound::{Excluded, Included, Unbounded};
 use core::ops::{self, Add, AddAssign, Index, IndexMut};
 use core::ptr;
 use core::str::pattern::Pattern;
@@ -67,7 +68,6 @@ use std_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER};
 
 use borrow::{Cow, ToOwned};
 use range::RangeArgument;
-use Bound::{Excluded, Included, Unbounded};
 use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
 use vec::Vec;
 use boxed::Box;
diff --git a/src/liballoc/tests/btree/map.rs b/src/liballoc/tests/btree/map.rs
index 2393101040d..6ebdb86cc4a 100644
--- a/src/liballoc/tests/btree/map.rs
+++ b/src/liballoc/tests/btree/map.rs
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 use std::collections::BTreeMap;
-use std::collections::Bound::{self, Excluded, Included, Unbounded};
 use std::collections::btree_map::Entry::{Occupied, Vacant};
+use std::ops::Bound::{self, Excluded, Included, Unbounded};
 use std::rc::Rc;
 
 use std::iter::FromIterator;
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index bcc999d7386..280570ecd65 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -75,6 +75,7 @@ use core::marker::PhantomData;
 use core::mem;
 #[cfg(not(test))]
 use core::num::Float;
+use core::ops::Bound::{Excluded, Included, Unbounded};
 use core::ops::{InPlace, Index, IndexMut, Place, Placer};
 use core::ops;
 use core::ptr;
@@ -87,7 +88,6 @@ use boxed::Box;
 use raw_vec::RawVec;
 use super::range::RangeArgument;
 use super::allocator::CollectionAllocErr;
-use Bound::{Excluded, Included, Unbounded};
 
 /// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
 ///
diff --git a/src/liballoc/vec_deque.rs b/src/liballoc/vec_deque.rs
index be6e8d0f22f..9efd730790d 100644
--- a/src/liballoc/vec_deque.rs
+++ b/src/liballoc/vec_deque.rs
@@ -21,6 +21,7 @@ use core::cmp::Ordering;
 use core::fmt;
 use core::iter::{repeat, FromIterator, FusedIterator};
 use core::mem;
+use core::ops::Bound::{Excluded, Included, Unbounded};
 use core::ops::{Index, IndexMut, Place, Placer, InPlace};
 use core::ptr;
 use core::ptr::NonNull;
@@ -33,7 +34,6 @@ use raw_vec::RawVec;
 
 use super::allocator::CollectionAllocErr;
 use super::range::RangeArgument;
-use Bound::{Excluded, Included, Unbounded};
 use super::vec::Vec;
 
 const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
diff --git a/src/libcore/ops/mod.rs b/src/libcore/ops/mod.rs
index 234970a81fa..b0e75135282 100644
--- a/src/libcore/ops/mod.rs
+++ b/src/libcore/ops/mod.rs
@@ -192,7 +192,7 @@ pub use self::index::{Index, IndexMut};
 pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
 
 #[stable(feature = "inclusive_range", since = "1.26.0")]
-pub use self::range::{RangeInclusive, RangeToInclusive};
+pub use self::range::{RangeInclusive, RangeToInclusive, Bound};
 
 #[unstable(feature = "try_trait", issue = "42327")]
 pub use self::try::Try;
diff --git a/src/libcore/ops/range.rs b/src/libcore/ops/range.rs
index be51f5239b0..dd44aedd09f 100644
--- a/src/libcore/ops/range.rs
+++ b/src/libcore/ops/range.rs
@@ -442,3 +442,54 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
 
 // RangeToInclusive<Idx> cannot impl From<RangeTo<Idx>>
 // because underflow would be possible with (..0).into()
+
+/// An endpoint of a range of keys.
+///
+/// # Examples
+///
+/// `Bound`s are range endpoints:
+///
+/// ```
+/// #![feature(collections_range)]
+///
+/// use std::collections::range::RangeArgument;
+/// use std::ops::Bound::*;
+///
+/// assert_eq!((..100).start(), Unbounded);
+/// assert_eq!((1..12).start(), Included(&1));
+/// assert_eq!((1..12).end(), Excluded(&12));
+/// ```
+///
+/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
+/// Note that in most cases, it's better to use range syntax (`1..5`) instead.
+///
+/// ```
+/// use std::collections::BTreeMap;
+/// use std::ops::Bound::{Excluded, Included, Unbounded};
+///
+/// let mut map = BTreeMap::new();
+/// map.insert(3, "a");
+/// map.insert(5, "b");
+/// map.insert(8, "c");
+///
+/// for (key, value) in map.range((Excluded(3), Included(8))) {
+///     println!("{}: {}", key, value);
+/// }
+///
+/// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
+/// ```
+///
+/// [`BTreeMap::range`]: ../../std/collections/btree_map/struct.BTreeMap.html#method.range
+#[stable(feature = "collections_bound", since = "1.17.0")]
+#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
+pub enum Bound<T> {
+    /// An inclusive bound.
+    #[stable(feature = "collections_bound", since = "1.17.0")]
+    Included(#[stable(feature = "collections_bound", since = "1.17.0")] T),
+    /// An exclusive bound.
+    #[stable(feature = "collections_bound", since = "1.17.0")]
+    Excluded(#[stable(feature = "collections_bound", since = "1.17.0")] T),
+    /// An infinite endpoint. Indicates that there is no bound in this direction.
+    #[stable(feature = "collections_bound", since = "1.17.0")]
+    Unbounded,
+}
diff --git a/src/librustc_data_structures/array_vec.rs b/src/librustc_data_structures/array_vec.rs
index 511c407d45a..b40f2f92237 100644
--- a/src/librustc_data_structures/array_vec.rs
+++ b/src/librustc_data_structures/array_vec.rs
@@ -19,8 +19,8 @@ use std::slice;
 use std::fmt;
 use std::mem;
 use std::collections::range::RangeArgument;
-use std::collections::Bound::{Excluded, Included, Unbounded};
 use std::mem::ManuallyDrop;
+use std::ops::Bound::{Excluded, Included, Unbounded};
 
 pub unsafe trait Array {
     type Element;
diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs
index be88f4e268a..e6f15a6119e 100644
--- a/src/libstd/collections/mod.rs
+++ b/src/libstd/collections/mod.rs
@@ -420,7 +420,8 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use alloc::Bound;
+#[rustc_deprecated(reason = "moved to `std::ops::Bound`", since = "1.26.0")]
+pub use ops::Bound;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use alloc::{BinaryHeap, BTreeMap, BTreeSet};
 #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/test/run-pass/sync-send-iterators-in-libcollections.rs b/src/test/run-pass/sync-send-iterators-in-libcollections.rs
index 903532e9bc8..e096fb3bbae 100644
--- a/src/test/run-pass/sync-send-iterators-in-libcollections.rs
+++ b/src/test/run-pass/sync-send-iterators-in-libcollections.rs
@@ -18,8 +18,8 @@ use std::collections::VecDeque;
 use std::collections::HashMap;
 use std::collections::HashSet;
 
-use std::collections::Bound::Included;
 use std::mem;
+use std::ops::Bound::Included;
 
 fn is_sync<T>(_: T) where T: Sync {}
 fn is_send<T>(_: T) where T: Send {}