From d8dfe1957b6541de8fe2797e248fe4bd2fac02d9 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Sun, 14 Sep 2014 15:57:55 -0700 Subject: [PATCH 1/2] Align with _mut conventions As per [RFC 52](https://github.com/rust-lang/rfcs/blob/master/active/0052-ownership-variants.md), use `_mut` suffixes to mark mutable variants, and `into_iter` for moving iterators. [breaking-change] --- src/libcollections/dlist.rs | 15 ++++- src/libcollections/ringbuf.rs | 8 ++- src/libcollections/smallintmap.rs | 18 ++++- src/libcollections/treemap.rs | 79 ++++++++++++++++------ src/libcollections/trie.rs | 30 +++++++-- src/libcollections/vec.rs | 56 ++++++++++++++-- src/libcore/option.rs | 16 ++++- src/libcore/ptr.rs | 6 +- src/libcore/result.rs | 16 ++++- src/libcore/slice.rs | 89 ++++++++++++++++++++----- src/librustc/middle/subst.rs | 4 +- src/libstd/collections/hashmap/map.rs | 16 ++++- src/libstd/collections/hashmap/table.rs | 4 +- src/libstd/io/buffered.rs | 2 +- src/libsync/comm/mod.rs | 2 +- 15 files changed, 293 insertions(+), 68 deletions(-) diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index 0ed946aa947db..cf5c1eed15cd0 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -475,9 +475,15 @@ impl DList { Items{nelem: self.len(), head: &self.list_head, tail: self.list_tail} } + /// Deprecated: use `iter_mut`. + #[deprecated = "use iter_mut"] + pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> { + self.iter_mut() + } + /// Provides a forward iterator with mutable references. #[inline] - pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> { + pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { let head_raw = match self.list_head { Some(ref mut h) => Rawlink::some(&mut **h), None => Rawlink::none(), @@ -490,10 +496,15 @@ impl DList { } } + /// Deprecated: use `into_iter`. + #[deprecated = "use into_iter"] + pub fn move_iter(self) -> MoveItems { + self.into_iter() + } /// Consumes the list into an iterator yielding elements by value. #[inline] - pub fn move_iter(self) -> MoveItems { + pub fn into_iter(self) -> MoveItems { MoveItems{list: self} } } diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index aa745ef39ee13..a3dc1d3003104 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -250,6 +250,12 @@ impl RingBuf { Items{index: 0, rindex: self.nelts, lo: self.lo, elts: self.elts.as_slice()} } + /// Deprecated: use `iter_mut` + #[deprecated = "use iter_mut"] + pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> { + self.iter_mut() + } + /// Returns a front-to-back iterator which returns mutable references. /// /// # Example @@ -267,7 +273,7 @@ impl RingBuf { /// let b: &[_] = &[&mut 3, &mut 1, &mut 2]; /// assert_eq!(buf.mut_iter().collect::>().as_slice(), b); /// ``` - pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> { + pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { let start_index = raw_index(self.lo, self.elts.len(), 0); let end_index = raw_index(self.lo, self.elts.len(), self.nelts); diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index dd3a639aeac78..aac34bfd15581 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -260,6 +260,12 @@ impl SmallIntMap { } } + /// Deprecated: use `iter_mut` + #[deprecated = "use iter_mut"] + pub fn mut_iter<'r>(&'r mut self) -> MutEntries<'r, V> { + self.iter_mut() + } + /// Returns an iterator visiting all key-value pairs in ascending order by the keys, /// with mutable references to the values. /// The iterator's element type is `(uint, &'r mut V)`. @@ -282,7 +288,7 @@ impl SmallIntMap { /// assert_eq!(value, &"x"); /// } /// ``` - pub fn mut_iter<'r>(&'r mut self) -> MutEntries<'r, V> { + pub fn iter_mut<'r>(&'r mut self) -> MutEntries<'r, V> { MutEntries { front: 0, back: self.v.len(), @@ -290,6 +296,14 @@ impl SmallIntMap { } } + /// Deprecated: use `into_iter` instead. + #[deprecated = "use into_iter"] + pub fn move_iter(&mut self) + -> FilterMap<(uint, Option), (uint, V), + Enumerate>>> { + self.into_iter() + } + /// Returns an iterator visiting all key-value pairs in ascending order by /// the keys, emptying (but not consuming) the original `SmallIntMap`. /// The iterator's element type is `(uint, &'r V)`. @@ -309,7 +323,7 @@ impl SmallIntMap { /// /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]); /// ``` - pub fn move_iter(&mut self) + pub fn into_iter(&mut self) -> FilterMap<(uint, Option), (uint, V), Enumerate>>> { diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index 354edae473fd5..0a7c84b5c0c55 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -226,10 +226,10 @@ impl Map for TreeMap { } impl MutableMap for TreeMap { - // See comments on def_tree_find_mut_with + // See comments on tree_find_with_mut #[inline] fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V> { - tree_find_mut_with(&mut self.root, |x| key.cmp(x)) + tree_find_with_mut(&mut self.root, |x| key.cmp(x)) } fn swap(&mut self, key: K, value: V) -> Option { @@ -361,6 +361,12 @@ impl TreeMap { RevEntries{iter: self.iter()} } + /// Deprecated: use `iter_mut`. + #[deprecated = "use iter_mut"] + pub fn mut_iter<'a>(&'a mut self) -> MutEntries<'a, K, V> { + self.iter_mut() + } + /// Gets a lazy forward iterator over the key-value pairs in the /// map, with the values being mutable. /// @@ -383,15 +389,21 @@ impl TreeMap { /// assert_eq!(map.find(&"b"), Some(&12)); /// assert_eq!(map.find(&"c"), Some(&3)); /// ``` - pub fn mut_iter<'a>(&'a mut self) -> MutEntries<'a, K, V> { + pub fn iter_mut<'a>(&'a mut self) -> MutEntries<'a, K, V> { MutEntries { stack: vec!(), - node: mut_deref(&mut self.root), + node: deref_mut(&mut self.root), remaining_min: self.length, remaining_max: self.length } } + /// Deprecated: use `rev_iter_mut`. + #[deprecated = "use rev_iter_mut"] + pub fn mut_rev_iter<'a>(&'a mut self) -> RevMutEntries<'a, K, V> { + self.rev_iter_mut() + } + /// Gets a lazy reverse iterator over the key-value pairs in the /// map, with the values being mutable. /// @@ -414,10 +426,15 @@ impl TreeMap { /// assert_eq!(map.find(&"b"), Some(&12)); /// assert_eq!(map.find(&"c"), Some(&13)); /// ``` - pub fn mut_rev_iter<'a>(&'a mut self) -> RevMutEntries<'a, K, V> { + pub fn rev_iter_mut<'a>(&'a mut self) -> RevMutEntries<'a, K, V> { RevMutEntries{iter: self.mut_iter()} } + /// Deprecated: use `into_iter`. + #[depreated = "use into_iter"] + pub fn move_iter(self) -> MoveEntries { + self.into_iter() + } /// Gets a lazy iterator that consumes the treemap. /// @@ -434,7 +451,7 @@ impl TreeMap { /// let vec: Vec<(&str, int)> = map.move_iter().collect(); /// assert_eq!(vec, vec![("a", 1), ("b", 2), ("c", 3)]); /// ``` - pub fn move_iter(self) -> MoveEntries { + pub fn into_iter(self) -> MoveEntries { let TreeMap { root: root, length: length } = self; let stk = match root { None => vec!(), @@ -477,6 +494,12 @@ impl TreeMap { tree_find_with(&self.root, f) } + /// Deprecated: use `find_with_mut`. + #[deprecated = "use find_with_mut"] + pub fn find_mut_with<'a>(&'a mut self, f:|&K| -> Ordering) -> Option<&'a mut V> { + self.find_with_mut(f) + } + /// Returns the value for which `f(key)` returns `Equal`. `f` is invoked /// with current key and guides tree navigation. That means `f` should /// be aware of natural ordering of the tree. @@ -497,8 +520,8 @@ impl TreeMap { /// assert_eq!(t.find(&"User-Agent"), Some(&new_ua)); /// ``` #[inline] - pub fn find_mut_with<'a>(&'a mut self, f:|&K| -> Ordering) -> Option<&'a mut V> { - tree_find_mut_with(&mut self.root, f) + pub fn find_with_mut<'a>(&'a mut self, f:|&K| -> Ordering) -> Option<&'a mut V> { + tree_find_with_mut(&mut self.root, f) } } @@ -594,15 +617,21 @@ impl TreeMap { /// Gets a lazy iterator that should be initialized using /// `traverse_left`/`traverse_right`/`traverse_complete`. - fn mut_iter_for_traversal<'a>(&'a mut self) -> MutEntries<'a, K, V> { + fn iter_mut_for_traversal<'a>(&'a mut self) -> MutEntries<'a, K, V> { MutEntries { stack: vec!(), - node: mut_deref(&mut self.root), + node: deref_mut(&mut self.root), remaining_min: 0, remaining_max: self.length } } + /// Deprecated: use `lower_bound_mut`. + #[deprecated = "use lower_bound_mut"] + pub fn mut_lower_bound<'a>(&'a mut self, k: &K) -> MutEntries<'a, K, V> { + self.lower_bound_mut(k) + } + /// Returns a lazy value iterator to the first key-value pair (with /// the value being mutable) whose key is not less than `k`. /// @@ -633,8 +662,14 @@ impl TreeMap { /// assert_eq!(map.find(&6), Some(&"changed")); /// assert_eq!(map.find(&8), Some(&"changed")); /// ``` - pub fn mut_lower_bound<'a>(&'a mut self, k: &K) -> MutEntries<'a, K, V> { - bound_setup!(self.mut_iter_for_traversal(), k, true) + pub fn lower_bound_mut<'a>(&'a mut self, k: &K) -> MutEntries<'a, K, V> { + bound_setup!(self.iter_mut_for_traversal(), k, true) + } + + /// Deprecated: use `upper_bound_mut`. + #[deprecated = "use upper_bound_mut"] + pub fn mut_upper_bound<'a>(&'a mut self, k: &K) -> MutEntries<'a, K, V> { + self.upper_bound_mut(k) } /// Returns a lazy iterator to the first key-value pair (with the @@ -667,8 +702,8 @@ impl TreeMap { /// assert_eq!(map.find(&6), Some(&"changed")); /// assert_eq!(map.find(&8), Some(&"changed")); /// ``` - pub fn mut_upper_bound<'a>(&'a mut self, k: &K) -> MutEntries<'a, K, V> { - bound_setup!(self.mut_iter_for_traversal(), k, false) + pub fn upper_bound_mut<'a>(&'a mut self, k: &K) -> MutEntries<'a, K, V> { + bound_setup!(self.iter_mut_for_traversal(), k, false) } } @@ -862,7 +897,7 @@ define_iterator! { define_iterator! { MutEntries, RevMutEntries, - deref = mut_deref, + deref = deref_mut, addr_mut = mut } @@ -877,7 +912,7 @@ fn deref<'a, K, V>(node: &'a Option>>) -> *const TreeNode(x: &mut Option>>) +fn deref_mut(x: &mut Option>>) -> *mut TreeNode { match *x { Some(ref mut n) => { @@ -1169,6 +1204,12 @@ impl TreeSet { RevSetItems{iter: self.map.rev_iter()} } + /// Deprecated: use `into_iter`. + #[deprecated = "use into_iter"] + pub fn move_iter(self) -> MoveSetItems { + self.into_iter() + } + /// Creates a consuming iterator, that is, one that moves each value out of the /// set in ascending order. The set cannot be used after calling this. /// @@ -1183,8 +1224,8 @@ impl TreeSet { /// assert_eq!(v, vec![1, 2, 3, 4, 5]); /// ``` #[inline] - pub fn move_iter(self) -> MoveSetItems { - self.map.move_iter().map(|(value, _)| value) + pub fn into_iter(self) -> MoveSetItems { + self.map.into_iter().map(|(value, _)| value) } /// Gets a lazy iterator pointing to the first value not less than `v` (greater or equal). @@ -1488,7 +1529,7 @@ fn tree_find_with<'r, K, V>(node: &'r Option>>, } // See comments above tree_find_with -fn tree_find_mut_with<'r, K, V>(node: &'r mut Option>>, +fn tree_find_with_mut<'r, K, V>(node: &'r mut Option>>, f: |&K| -> Ordering) -> Option<&'r mut V> { let mut current = node; diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index 7d60d3a85e128..f447bcba917a8 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -267,6 +267,12 @@ impl TrieMap { iter } + /// Deprecated: use `iter_mut`. + #[deprecated = "use iter_mut"] + pub fn mut_iter<'a>(&'a mut self) -> MutEntries<'a, T> { + self.iter_mut() + } + /// Gets an iterator over the key-value pairs in the map, with the /// ability to mutate the values. /// @@ -284,7 +290,7 @@ impl TrieMap { /// assert_eq!(map.find(&2), Some(&-2)); /// assert_eq!(map.find(&3), Some(&-3)); /// ``` - pub fn mut_iter<'a>(&'a mut self) -> MutEntries<'a, T> { + pub fn iter_mut<'a>(&'a mut self) -> MutEntries<'a, T> { let mut iter = unsafe {MutEntries::new()}; iter.stack[0] = self.root.children.mut_iter(); iter.length = 1; @@ -425,13 +431,19 @@ impl TrieMap { } // If `upper` is true then returns upper_bound else returns lower_bound. #[inline] - fn mut_bound<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> { + fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> { bound!(MutEntries, self = self, key = key, is_upper = upper, slice_from = mut_slice_from, iter = mut_iter, mutability = mut) } + /// Deprecated: use `lower_bound_mut`. + #[deprecated = "use lower_bound_mut"] + pub fn mut_lower_bound<'a>(&'a mut self, key: uint) -> MutEntries<'a, T> { + self.lower_bound_mut(key) + } + /// Gets an iterator pointing to the first key-value pair whose key is not less than `key`. /// If all keys in the map are less than `key` an empty iterator is returned. /// @@ -453,8 +465,14 @@ impl TrieMap { /// assert_eq!(map.find(&4), Some(&"changed")); /// assert_eq!(map.find(&6), Some(&"changed")); /// ``` - pub fn mut_lower_bound<'a>(&'a mut self, key: uint) -> MutEntries<'a, T> { - self.mut_bound(key, false) + pub fn lower_bound_mut<'a>(&'a mut self, key: uint) -> MutEntries<'a, T> { + self.bound_mut(key, false) + } + + /// Deprecated: use `upper_bound_mut`. + #[deprecated = "use upper_bound_mut"] + pub fn mut_upper_bound<'a>(&'a mut self, key: uint) -> MutEntries<'a, T> { + self.upper_bound_mut(key) } /// Gets an iterator pointing to the first key-value pair whose key is greater than `key`. @@ -478,8 +496,8 @@ impl TrieMap { /// assert_eq!(map.find(&4), Some(&"b")); /// assert_eq!(map.find(&6), Some(&"changed")); /// ``` - pub fn mut_upper_bound<'a>(&'a mut self, key: uint) -> MutEntries<'a, T> { - self.mut_bound(key, true) + pub fn upper_bound_mut<'a>(&'a mut self, key: uint) -> MutEntries<'a, T> { + self.bound_mut(key, true) } } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 5215e8aaab88f..3557390ef9651 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -724,6 +724,12 @@ impl Vec { } } + /// Deprecated: use `into_iter`. + #[deprecated = "use into_iter"] + pub fn move_iter(self) -> MoveItems { + self.into_iter() + } + /// Creates a consuming iterator, that is, one that moves each /// value out of the vector (from start to end). The vector cannot /// be used after calling this. @@ -738,7 +744,7 @@ impl Vec { /// } /// ``` #[inline] - pub fn move_iter(self) -> MoveItems { + pub fn into_iter(self) -> MoveItems { unsafe { let iter = mem::transmute(self.as_slice().iter()); let ptr = self.ptr; @@ -822,6 +828,11 @@ impl Vec { self.as_slice().iter() } + /// Deprecated: use `iter_mut`. + #[deprecated = "use iter_mut"] + pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a,T> { + self.iter_mut() + } /// Returns an iterator over mutable references to the elements of the /// vector in order. @@ -835,7 +846,7 @@ impl Vec { /// } /// ``` #[inline] - pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a,T> { + pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a,T> { self.as_mut_slice().mut_iter() } @@ -927,6 +938,12 @@ impl Vec { self.as_slice().last() } + /// Deprecated: use `last_mut`. + #[deprecated = "use last_mut"] + pub fn mut_last<'a>(&'a mut self) -> Option<&'a mut T> { + self.last_mut() + } + /// Returns a mutable reference to the last element of a vector, or `None` /// if it is empty. /// @@ -938,7 +955,7 @@ impl Vec { /// assert_eq!(vec, vec![1i, 2, 4]); /// ``` #[inline] - pub fn mut_last<'a>(&'a mut self) -> Option<&'a mut T> { + pub fn last_mut<'a>(&'a mut self) -> Option<&'a mut T> { self.as_mut_slice().mut_last() } @@ -1105,6 +1122,13 @@ impl Vec { self.extend(other.move_iter()); } + /// Deprecated: use `slice_mut`. + #[deprecated = "use slice_mut"] + pub fn mut_slice<'a>(&'a mut self, start: uint, end: uint) + -> &'a mut [T] { + self.slice_mut(start, end) + } + /// Returns a mutable slice of `self` between `start` and `end`. /// /// # Failure @@ -1119,11 +1143,17 @@ impl Vec { /// assert!(vec.mut_slice(0, 2) == [1, 2]); /// ``` #[inline] - pub fn mut_slice<'a>(&'a mut self, start: uint, end: uint) + pub fn slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] { self.as_mut_slice().mut_slice(start, end) } + /// Deprecated: use "slice_from_mut". + #[deprecated = "use slice_from_mut"] + pub fn mut_slice_from<'a>(&'a mut self, start: uint) -> &'a mut [T] { + self.slice_from_mut(start) + } + /// Returns a mutable slice of `self` from `start` to the end of the `Vec`. /// /// # Failure @@ -1137,10 +1167,16 @@ impl Vec { /// assert!(vec.mut_slice_from(2) == [3, 4]); /// ``` #[inline] - pub fn mut_slice_from<'a>(&'a mut self, start: uint) -> &'a mut [T] { + pub fn slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T] { self.as_mut_slice().mut_slice_from(start) } + /// Deprecated: use `slice_to_mut`. + #[deprecated = "use slice_to_mut"] + pub fn mut_slice_to<'a>(&'a mut self, end: uint) -> &'a mut [T] { + self.slice_to_mut(end) + } + /// Returns a mutable slice of `self` from the start of the `Vec` to `end`. /// /// # Failure @@ -1154,10 +1190,16 @@ impl Vec { /// assert!(vec.mut_slice_to(2) == [1, 2]); /// ``` #[inline] - pub fn mut_slice_to<'a>(&'a mut self, end: uint) -> &'a mut [T] { + pub fn slice_to_mut<'a>(&'a mut self, end: uint) -> &'a mut [T] { self.as_mut_slice().mut_slice_to(end) } + /// Deprecated: use `split_at_mut`. + #[deprecated = "use split_at_mut"] + pub fn mut_split_at<'a>(&'a mut self, mid: uint) -> (&'a mut [T], &'a mut [T]) { + self.split_at_mut(mid) + } + /// Returns a pair of mutable slices that divides the `Vec` at an index. /// /// The first will contain all indices from `[0, mid)` (excluding @@ -1193,7 +1235,7 @@ impl Vec { /// } /// ``` #[inline] - pub fn mut_split_at<'a>(&'a mut self, mid: uint) -> (&'a mut [T], &'a mut [T]) { + pub fn split_at_mut<'a>(&'a mut self, mid: uint) -> (&'a mut [T], &'a mut [T]) { self.as_mut_slice().mut_split_at(mid) } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 537d78a67feb2..cd6e8f3e666e1 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -372,17 +372,29 @@ impl Option { Item{opt: self.as_ref()} } + /// Deprecated: use `iter_mut` + #[deprecated = "use iter_mut"] + pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> { + self.iter_mut() + } + /// Returns a mutable iterator over the possibly contained value. #[inline] #[unstable = "waiting for iterator conventions"] - pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> { + pub fn iter_mut<'r>(&'r mut self) -> Item<&'r mut T> { Item{opt: self.as_mut()} } + /// Deprecated: use `into_iter`. + #[deprecated = "use into_iter"] + pub fn move_iter(self) -> Item { + self.into_iter() + } + /// Returns a consuming iterator over the possibly contained value. #[inline] #[unstable = "waiting for iterator conventions"] - pub fn move_iter(self) -> Item { + pub fn into_iter(self) -> Item { Item{opt: self} } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index d1bea25dded41..42416a640bf65 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -113,6 +113,10 @@ pub use intrinsics::set_memory; #[unstable = "may need a different name after pending changes to pointer types"] pub fn null() -> *const T { 0 as *const T } +/// Deprecated: use `null_mut`. +#[deprecated = "use null_mut"] +pub fn mut_null() -> *mut T { null_mut() } + /// Create an unsafe mutable null pointer. /// /// # Example @@ -125,7 +129,7 @@ pub fn null() -> *const T { 0 as *const T } /// ``` #[inline] #[unstable = "may need a different name after pending changes to pointer types"] -pub fn mut_null() -> *mut T { 0 as *mut T } +pub fn null_mut() -> *mut T { 0 as *mut T } /// Zeroes out `count * size_of::` bytes of memory at `dst` #[inline] diff --git a/src/libcore/result.rs b/src/libcore/result.rs index bf351ecc89b1f..426ae8f09298c 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -500,17 +500,29 @@ impl Result { Item{opt: self.as_ref().ok()} } + /// Deprecated: use `iter_mut`. + #[deprecated = "use iter_mut"] + pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> { + self.iter_mut() + } + /// Returns a mutable iterator over the possibly contained value. #[inline] #[unstable = "waiting for iterator conventions"] - pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> { + pub fn iter_mut<'r>(&'r mut self) -> Item<&'r mut T> { Item{opt: self.as_mut().ok()} } + /// Deprecated: `use into_iter`. + #[deprecated = "use into_iter"] + pub fn move_iter(self) -> Item { + self.into_iter() + } + /// Returns a consuming iterator over the possibly contained value. #[inline] #[unstable = "waiting for iterator conventions"] - pub fn move_iter(self) -> Item { + pub fn into_iter(self) -> Item { Item{opt: self.ok()} } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index cc2b01e3bb58b..05b0c1e4f70ba 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -486,38 +486,80 @@ pub trait MutableSlice<'a, T> { /// Primarily intended for getting a &mut [T] from a [T, ..N]. fn as_mut_slice(self) -> &'a mut [T]; + /// Deprecated: use `slice_mut`. + #[deprecated = "use slice_mut"] + fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] { + self.slice_mut(start, end) + } + /// Returns a mutable subslice spanning the interval [`start`, `end`). /// /// Fails when the end of the new slice lies beyond the end of the /// original slice (i.e. when `end > self.len()`) or when `start > end`. /// /// Slicing with `start` equal to `end` yields an empty slice. - fn mut_slice(self, start: uint, end: uint) -> &'a mut [T]; + fn slice_mut(self, start: uint, end: uint) -> &'a mut [T]; + + /// Deprecated: use `slice_from_mut`. + #[deprecated = "use slice_from_mut"] + fn mut_slice_from(self, start: uint) -> &'a mut [T] { + self.slice_from_mut(start) + } /// Returns a mutable subslice from `start` to the end of the slice. /// /// Fails when `start` is strictly greater than the length of the original slice. /// /// Slicing from `self.len()` yields an empty slice. - fn mut_slice_from(self, start: uint) -> &'a mut [T]; + fn slice_from_mut(self, start: uint) -> &'a mut [T]; + + /// Deprecated: use `slice_to_mut`. + #[deprecated = "use slice_to_mut"] + fn mut_slice_to(self, end: uint) -> &'a mut [T] { + self.slice_to_mut(end) + } /// Returns a mutable subslice from the start of the slice to `end`. /// /// Fails when `end` is strictly greater than the length of the original slice. /// /// Slicing to `0` yields an empty slice. - fn mut_slice_to(self, end: uint) -> &'a mut [T]; + fn slice_to_mut(self, end: uint) -> &'a mut [T]; + + /// Deprecated: use `iter_mut`. + #[deprecated = "use iter_mut"] + fn mut_iter(self) -> MutItems<'a, T> { + self.iter_mut() + } /// Returns an iterator that allows modifying each value - fn mut_iter(self) -> MutItems<'a, T>; + fn iter_mut(self) -> MutItems<'a, T>; + + /// Deprecated: use `last_mut`. + #[deprecated = "use last_mut"] + fn mut_last(self) -> Option<&'a mut T> { + self.last_mut() + } /// Returns a mutable pointer to the last item in the vector. - fn mut_last(self) -> Option<&'a mut T>; + fn last_mut(self) -> Option<&'a mut T>; + + /// Deprecated: use `split_mut`. + #[deprecated = "use split_mut"] + fn mut_split(self, pred: |&T|: 'a -> bool) -> MutSplits<'a, T> { + self.split_mut(pred) + } /// Returns an iterator over the mutable subslices of the vector /// which are separated by elements that match `pred`. The /// matched element is not contained in the subslices. - fn mut_split(self, pred: |&T|: 'a -> bool) -> MutSplits<'a, T>; + fn split_mut(self, pred: |&T|: 'a -> bool) -> MutSplits<'a, T>; + + /// Deprecated: use `chunks_mut`. + #[deprecated = "use chunks_mut"] + fn mut_chunks(self, chunk_size: uint) -> MutChunks<'a, T> { + self.chunks_mut(chunk_size) + } /** * Returns an iterator over `chunk_size` elements of the vector at a time. @@ -529,7 +571,7 @@ pub trait MutableSlice<'a, T> { * * Fails if `chunk_size` is 0. */ - fn mut_chunks(self, chunk_size: uint) -> MutChunks<'a, T>; + fn chunks_mut(self, chunk_size: uint) -> MutChunks<'a, T>; /** * Returns a mutable reference to the first element in this slice @@ -587,6 +629,11 @@ pub trait MutableSlice<'a, T> { /// ``` fn swap(self, a: uint, b: uint); + /// Deprecated: use `split_at_mut`. + #[deprecated = "use split_at_mut"] + fn mut_split_at(self, mid: uint) -> (&'a mut [T], &'a mut [T]) { + self.split_at_mut(mid) + } /// Divides one `&mut` into two at an index. /// @@ -620,7 +667,7 @@ pub trait MutableSlice<'a, T> { /// assert!(right == &mut []); /// } /// ``` - fn mut_split_at(self, mid: uint) -> (&'a mut [T], &'a mut [T]); + fn split_at_mut(self, mid: uint) -> (&'a mut [T], &'a mut [T]); /// Reverse the order of elements in a vector, in place. /// @@ -633,8 +680,14 @@ pub trait MutableSlice<'a, T> { /// ``` fn reverse(self); + /// Deprecated: use `unsafe_mut`. + #[deprecated = "use unsafe_mut"] + unsafe fn unsafe_mut_ref(self, index: uint) -> &'a mut T { + self.unsafe_mut(index) + } + /// Returns an unsafe mutable pointer to the element in index - unsafe fn unsafe_mut_ref(self, index: uint) -> &'a mut T; + unsafe fn unsafe_mut(self, index: uint) -> &'a mut T; /// Return an unsafe mutable pointer to the vector's buffer. /// @@ -701,7 +754,7 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { #[inline] fn as_mut_slice(self) -> &'a mut [T] { self } - fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] { + fn slice_mut(self, start: uint, end: uint) -> &'a mut [T] { assert!(start <= end); assert!(end <= self.len()); unsafe { @@ -713,18 +766,18 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { } #[inline] - fn mut_slice_from(self, start: uint) -> &'a mut [T] { + fn slice_from_mut(self, start: uint) -> &'a mut [T] { let len = self.len(); self.mut_slice(start, len) } #[inline] - fn mut_slice_to(self, end: uint) -> &'a mut [T] { + fn slice_to_mut(self, end: uint) -> &'a mut [T] { self.mut_slice(0, end) } #[inline] - fn mut_split_at(self, mid: uint) -> (&'a mut [T], &'a mut [T]) { + fn split_at_mut(self, mid: uint) -> (&'a mut [T], &'a mut [T]) { unsafe { let len = self.len(); let self2: &'a mut [T] = mem::transmute_copy(&self); @@ -733,7 +786,7 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { } #[inline] - fn mut_iter(self) -> MutItems<'a, T> { + fn iter_mut(self) -> MutItems<'a, T> { unsafe { let p = self.as_mut_ptr(); if mem::size_of::() == 0 { @@ -751,19 +804,19 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { } #[inline] - fn mut_last(self) -> Option<&'a mut T> { + fn last_mut(self) -> Option<&'a mut T> { let len = self.len(); if len == 0 { return None; } Some(&mut self[len - 1]) } #[inline] - fn mut_split(self, pred: |&T|: 'a -> bool) -> MutSplits<'a, T> { + fn split_mut(self, pred: |&T|: 'a -> bool) -> MutSplits<'a, T> { MutSplits { v: self, pred: pred, finished: false } } #[inline] - fn mut_chunks(self, chunk_size: uint) -> MutChunks<'a, T> { + fn chunks_mut(self, chunk_size: uint) -> MutChunks<'a, T> { assert!(chunk_size > 0); MutChunks { v: self, chunk_size: chunk_size } } @@ -817,7 +870,7 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { } #[inline] - unsafe fn unsafe_mut_ref(self, index: uint) -> &'a mut T { + unsafe fn unsafe_mut(self, index: uint) -> &'a mut T { transmute((self.repr().data as *mut T).offset(index as int)) } diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index d7e6fd18ed563..5559f222fe219 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -32,7 +32,7 @@ trait HomogeneousTuple3 { fn as_slice<'a>(&'a self) -> &'a [T]; fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T]; fn iter<'a>(&'a self) -> Items<'a, T>; - fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T>; + fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T>; fn get<'a>(&'a self, index: uint) -> Option<&'a T>; fn get_mut<'a>(&'a mut self, index: uint) -> Option<&'a mut T>; } @@ -63,7 +63,7 @@ impl HomogeneousTuple3 for (T, T, T) { slice.iter() } - fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> { + fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { self.as_mut_slice().mut_iter() } diff --git a/src/libstd/collections/hashmap/map.rs b/src/libstd/collections/hashmap/map.rs index a50c6a59f7e04..4a58f4e75de70 100644 --- a/src/libstd/collections/hashmap/map.rs +++ b/src/libstd/collections/hashmap/map.rs @@ -1193,6 +1193,12 @@ impl, V, S, H: Hasher> HashMap { Entries { inner: self.table.iter() } } + /// Deprecated: use `iter_mut`. + #[deprecated = "use iter_mut"] + pub fn mut_iter(&mut self) -> MutEntries { + self.iter_mut() + } + /// An iterator visiting all key-value pairs in arbitrary order, /// with mutable references to the values. /// Iterator element type is `(&'a K, &'a mut V)`. @@ -1216,10 +1222,16 @@ impl, V, S, H: Hasher> HashMap { /// println!("key: {} val: {}", key, val); /// } /// ``` - pub fn mut_iter(&mut self) -> MutEntries { + pub fn iter_mut(&mut self) -> MutEntries { MutEntries { inner: self.table.mut_iter() } } + /// Deprecated: use `into_iter`. + #[deprecated = "use into_iter"] + pub fn move_iter(self) -> MoveEntries { + self.into_iter() + } + /// Creates a consuming iterator, that is, one that moves each key-value /// pair out of the map in arbitrary order. The map cannot be used after /// calling this. @@ -1237,7 +1249,7 @@ impl, V, S, H: Hasher> HashMap { /// // Not possible with .iter() /// let vec: Vec<(&str, int)> = map.move_iter().collect(); /// ``` - pub fn move_iter(self) -> MoveEntries { + pub fn into_iter(self) -> MoveEntries { MoveEntries { inner: self.table.move_iter().map(|(_, k, v)| (k, v)) } diff --git a/src/libstd/collections/hashmap/table.rs b/src/libstd/collections/hashmap/table.rs index 2edb8cd092e0c..33e760f11cea4 100644 --- a/src/libstd/collections/hashmap/table.rs +++ b/src/libstd/collections/hashmap/table.rs @@ -674,14 +674,14 @@ impl RawTable { } } - pub fn mut_iter(&mut self) -> MutEntries { + pub fn iter_mut(&mut self) -> MutEntries { MutEntries { iter: self.raw_buckets(), elems_left: self.size(), } } - pub fn move_iter(self) -> MoveEntries { + pub fn into_iter(self) -> MoveEntries { MoveEntries { iter: self.raw_buckets(), table: self, diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 0c63f1a901f5a..76f86d66ff546 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -265,7 +265,7 @@ impl Writer for LineBufferedWriter { struct InternalBufferedWriter(BufferedWriter); impl InternalBufferedWriter { - fn get_mut_ref<'a>(&'a mut self) -> &'a mut BufferedWriter { + fn get_mut<'a>(&'a mut self) -> &'a mut BufferedWriter { let InternalBufferedWriter(ref mut w) = *self; return w; } diff --git a/src/libsync/comm/mod.rs b/src/libsync/comm/mod.rs index 9177fa4a6b446..e46f52b3ad7b9 100644 --- a/src/libsync/comm/mod.rs +++ b/src/libsync/comm/mod.rs @@ -449,7 +449,7 @@ enum Flavor { #[doc(hidden)] trait UnsafeFlavor { fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell>; - unsafe fn mut_inner<'a>(&'a self) -> &'a mut Flavor { + unsafe fn inner_mut<'a>(&'a self) -> &'a mut Flavor { &mut *self.inner_unsafe().get() } unsafe fn inner<'a>(&'a self) -> &'a Flavor { From fc525eeb4ec3443d29bce677f589b19f31c189bb Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Sun, 14 Sep 2014 20:27:36 -0700 Subject: [PATCH 2/2] Fallout from renaming --- src/compiletest/compiletest.rs | 4 +- src/compiletest/procsrv.rs | 4 +- src/compiletest/runtest.rs | 4 +- src/doc/guide-tasks.md | 2 +- src/doc/guide.md | 2 +- src/liballoc/heap.rs | 4 +- src/liballoc/libc_heap.rs | 6 +- src/libarena/lib.rs | 2 +- src/libcollections/bitv.rs | 10 +-- src/libcollections/dlist.rs | 42 +++++------ src/libcollections/ringbuf.rs | 30 ++++---- src/libcollections/slice.rs | 64 ++++++++--------- src/libcollections/smallintmap.rs | 20 +++--- src/libcollections/treemap.rs | 66 ++++++++--------- src/libcollections/trie.rs | 36 +++++----- src/libcollections/vec.rs | 72 +++++++++---------- src/libcore/fmt/float.rs | 4 +- src/libcore/fmt/mod.rs | 2 +- src/libcore/fmt/num.rs | 4 +- src/libcore/iter.rs | 6 +- src/libcore/ptr.rs | 4 +- src/libcore/slice.rs | 38 +++++----- src/libcoretest/iter.rs | 2 +- src/libcoretest/option.rs | 4 +- src/libcoretest/result.rs | 4 +- src/libglob/lib.rs | 4 +- src/libgraphviz/lib.rs | 6 +- src/libgreen/basic.rs | 6 +- src/libgreen/lib.rs | 8 +-- src/libnative/io/file_unix.rs | 2 +- src/libnative/io/file_windows.rs | 18 ++--- src/libnative/io/helper_thread.rs | 2 +- src/libnative/io/mod.rs | 2 +- src/libnative/io/net.rs | 4 +- src/libnative/io/pipe_unix.rs | 2 +- src/libnative/io/pipe_windows.rs | 22 +++--- src/libnative/io/process.rs | 34 ++++----- src/libnative/io/timer_unix.rs | 8 +-- src/libnative/io/timer_windows.rs | 12 ++-- src/libnative/io/tty_windows.rs | 4 +- src/libnative/io/util.rs | 14 ++-- src/librand/distributions/mod.rs | 2 +- src/librand/isaac.rs | 4 +- src/librand/lib.rs | 2 +- src/librbml/io.rs | 2 +- src/libregex/compile.rs | 2 +- src/libregex/parse.rs | 6 +- src/libregex/test/bench.rs | 2 +- src/libregex/vm.rs | 4 +- src/libregex_macros/lib.rs | 4 +- src/librustc/back/link.rs | 6 +- src/librustc/back/lto.rs | 2 +- src/librustc/back/write.rs | 2 +- src/librustc/driver/config.rs | 8 +-- src/librustc/driver/driver.rs | 8 +-- src/librustc/driver/mod.rs | 12 ++-- src/librustc/driver/pretty.rs | 2 +- src/librustc/front/config.rs | 28 ++++---- src/librustc/front/test.rs | 10 +-- src/librustc/lint/context.rs | 10 +-- src/librustc/metadata/creader.rs | 4 +- src/librustc/metadata/decoder.rs | 4 +- src/librustc/metadata/encoder.rs | 8 +-- src/librustc/metadata/loader.rs | 8 +-- src/librustc/middle/astencode.rs | 10 +-- .../borrowck/gather_loans/move_error.rs | 2 +- src/librustc/middle/cfg/construct.rs | 4 +- src/librustc/middle/check_match.rs | 20 +++--- src/librustc/middle/dataflow.rs | 12 ++-- src/librustc/middle/dead.rs | 2 +- src/librustc/middle/dependency_format.rs | 2 +- src/librustc/middle/pat_util.rs | 2 +- src/librustc/middle/resolve.rs | 2 +- src/librustc/middle/subst.rs | 14 ++-- src/librustc/middle/traits/fulfill.rs | 3 +- src/librustc/middle/trans/_match.rs | 2 +- src/librustc/middle/trans/asm.rs | 2 +- src/librustc/middle/trans/base.rs | 8 +-- src/librustc/middle/trans/builder.rs | 2 +- src/librustc/middle/trans/cabi_x86_64.rs | 2 +- src/librustc/middle/trans/cleanup.rs | 4 +- src/librustc/middle/trans/closure.rs | 2 +- src/librustc/middle/trans/context.rs | 4 +- src/librustc/middle/trans/debuginfo.rs | 30 ++++---- src/librustc/middle/trans/foreign.rs | 2 +- src/librustc/middle/trans/meth.rs | 6 +- src/librustc/middle/ty.rs | 2 +- src/librustc/middle/typeck/astconv.rs | 4 +- src/librustc/middle/typeck/check/_match.rs | 2 +- src/librustc/middle/typeck/check/method.rs | 4 +- src/librustc/middle/typeck/check/regionck.rs | 4 +- src/librustc/middle/typeck/collect.rs | 6 +- .../middle/typeck/infer/error_reporting.rs | 4 +- src/librustc/plugin/registry.rs | 2 +- src/librustc_back/rpath.rs | 2 +- src/librustc_back/sha2.rs | 30 ++++---- src/librustdoc/clean/inline.rs | 16 ++--- src/librustdoc/clean/mod.rs | 30 ++++---- src/librustdoc/core.rs | 2 +- src/librustdoc/flock.rs | 4 +- src/librustdoc/fold.rs | 12 ++-- src/librustdoc/html/render.rs | 8 +-- src/librustdoc/html/toc.rs | 2 +- src/librustdoc/lib.rs | 4 +- src/librustdoc/test.rs | 4 +- src/librustrt/at_exit_imp.rs | 2 +- src/librustrt/exclusive.rs | 2 +- src/librustrt/local_heap.rs | 6 +- src/librustrt/local_ptr.rs | 4 +- src/librustrt/mutex.rs | 2 +- src/librustrt/thread.rs | 6 +- src/librustrt/util.rs | 2 +- src/librustuv/addrinfo.rs | 8 +-- src/librustuv/lib.rs | 12 ++-- src/librustuv/process.rs | 2 +- src/librustuv/stream.rs | 2 +- src/librustuv/tty.rs | 2 +- src/librustuv/uvio.rs | 2 +- src/libserialize/hex.rs | 2 +- src/libserialize/json.rs | 8 +-- src/libstd/ascii.rs | 4 +- src/libstd/c_vec.rs | 6 +- src/libstd/collections/hashmap/map.rs | 20 +++--- src/libstd/collections/hashmap/set.rs | 14 ++-- src/libstd/collections/hashmap/table.rs | 2 +- src/libstd/collections/lru_cache.rs | 4 +- src/libstd/dynamic_lib.rs | 2 +- src/libstd/io/buffered.rs | 8 +-- src/libstd/io/comm_adapters.rs | 2 +- src/libstd/io/fs.rs | 8 +-- src/libstd/io/mem.rs | 8 +-- src/libstd/io/mod.rs | 4 +- src/libstd/io/net/addrinfo.rs | 4 +- src/libstd/io/net/ip.rs | 4 +- src/libstd/io/net/udp.rs | 2 +- src/libstd/io/process.rs | 4 +- src/libstd/io/test.rs | 4 +- src/libstd/io/util.rs | 10 +-- src/libstd/os.rs | 20 +++--- src/libstd/path/posix.rs | 4 +- src/libstd/path/windows.rs | 2 +- src/libstd/rand/mod.rs | 2 +- src/libstd/rt/backtrace.rs | 4 +- src/libstd/sync/task_pool.rs | 2 +- src/libsync/comm/mod.rs | 26 +++---- src/libsync/deque.rs | 8 +-- src/libsync/lock.rs | 6 +- src/libsync/mpmc_bounded_queue.rs | 2 +- src/libsync/raw.rs | 8 +-- src/libsyntax/ast_map/mod.rs | 2 +- src/libsyntax/attr.rs | 4 +- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/build.rs | 4 +- src/libsyntax/ext/concat.rs | 2 +- src/libsyntax/ext/deriving/cmp/totaleq.rs | 2 +- src/libsyntax/ext/deriving/generic/mod.rs | 18 ++--- src/libsyntax/ext/env.rs | 2 +- src/libsyntax/ext/expand.rs | 26 +++---- src/libsyntax/ext/format.rs | 8 +-- src/libsyntax/ext/quote.rs | 2 +- src/libsyntax/ext/tt/macro_parser.rs | 2 +- src/libsyntax/ext/tt/transcribe.rs | 12 ++-- src/libsyntax/fold.rs | 22 +++--- src/libsyntax/owned_slice.rs | 4 +- src/libsyntax/parse/parser.rs | 22 +++--- src/libsyntax/util/small_vector.rs | 20 ++++-- src/libterm/terminfo/parm.rs | 6 +- src/libtest/lib.rs | 14 ++-- src/libtest/stats.rs | 2 +- src/libtime/lib.rs | 2 +- src/test/bench/core-uint-to-str.rs | 2 +- src/test/bench/msgsend-pipes-shared.rs | 4 +- src/test/bench/msgsend-pipes.rs | 4 +- src/test/bench/msgsend-ring-mutex-arcs.rs | 4 +- src/test/bench/msgsend-ring-rw-arcs.rs | 4 +- src/test/bench/noise.rs | 4 +- src/test/bench/shootout-ackermann.rs | 2 +- src/test/bench/shootout-binarytrees.rs | 2 +- src/test/bench/shootout-fannkuch-redux.rs | 12 ++-- src/test/bench/shootout-fasta-redux.rs | 4 +- src/test/bench/shootout-fibo.rs | 2 +- src/test/bench/shootout-k-nucleotide-pipes.rs | 2 +- src/test/bench/shootout-k-nucleotide.rs | 6 +- src/test/bench/shootout-mandelbrot.rs | 4 +- src/test/bench/shootout-meteor.rs | 6 +- src/test/bench/shootout-nbody.rs | 2 +- src/test/bench/shootout-pfib.rs | 4 +- src/test/bench/shootout-regex-dna.rs | 4 +- src/test/bench/shootout-reverse-complement.rs | 10 +-- src/test/bench/std-smallintmap.rs | 2 +- .../bench/task-perf-jargon-metal-smoke.rs | 2 +- src/test/bench/task-perf-one-million.rs | 6 +- src/test/bench/task-perf-spawnalot.rs | 2 +- ...rowck-move-out-of-overloaded-auto-deref.rs | 2 +- .../moves-based-on-type-access-to-field.rs | 2 +- .../compile-fail/moves-based-on-type-exprs.rs | 4 +- .../compile-fail/std-uncopyable-atomics.rs | 2 +- src/test/compile-fail/vec-mut-iter-borrow.rs | 2 +- src/test/debuginfo/type-names.rs | 6 +- src/test/run-pass/autobind.rs | 2 +- src/test/run-pass/const-vec-of-fns.rs | 2 +- src/test/run-pass/dst-raw.rs | 2 +- src/test/run-pass/issue-16151.rs | 2 +- ...ility-inherits-through-fixed-length-vec.rs | 2 +- src/test/run-pass/newtype-polymorphic.rs | 2 +- src/test/run-pass/realloc-16687.rs | 2 +- src/test/run-pass/reflect-visit-type.rs | 2 +- src/test/run-pass/send_str_treemap.rs | 2 +- src/test/run-pass/task-comm-3.rs | 2 +- src/test/run-pass/vec-dst.rs | 6 +- 210 files changed, 793 insertions(+), 782 deletions(-) diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 6c6cd6f610f5b..8188cb17b27c8 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -259,7 +259,7 @@ pub fn run_tests(config: &Config) { // parallel (especially when we have lots and lots of child processes). // For context, see #8904 io::test::raise_fd_limit(); - let res = test::run_tests_console(&opts, tests.move_iter().collect()); + let res = test::run_tests_console(&opts, tests.into_iter().collect()); match res { Ok(true) => {} Ok(false) => fail!("Some tests failed"), @@ -400,4 +400,4 @@ fn extract_gdb_version(full_version_line: Option) -> Option { }, _ => None } -} \ No newline at end of file +} diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 2c3aa88a68083..f3f860d470d93 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -40,7 +40,7 @@ pub fn run(lib_path: &str, let mut cmd = Command::new(prog); cmd.args(args); add_target_env(&mut cmd, lib_path, aux_path); - for (key, val) in env.move_iter() { + for (key, val) in env.into_iter() { cmd.env(key, val); } @@ -72,7 +72,7 @@ pub fn run_background(lib_path: &str, let mut cmd = Command::new(prog); cmd.args(args); add_target_env(&mut cmd, lib_path, aux_path); - for (key, val) in env.move_iter() { + for (key, val) in env.into_iter() { cmd.env(key, val); } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index c61db4ed2cfd9..40acb7da1750a 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -768,7 +768,7 @@ fn cleanup_debug_info_options(options: &Option) -> Option { "--debuginfo".to_string() ]; let new_options = - split_maybe_args(options).move_iter() + split_maybe_args(options).into_iter() .filter(|x| !options_to_remove.contains(x)) .collect::>() .connect(" "); @@ -1461,7 +1461,7 @@ fn _arm_exec_compiled_test(config: &Config, // run test via adb_run_wrapper runargs.push("shell".to_string()); - for (key, val) in env.move_iter() { + for (key, val) in env.into_iter() { runargs.push(format!("{}={}", key, val)); } runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir)); diff --git a/src/doc/guide-tasks.md b/src/doc/guide-tasks.md index 687f2a3a83343..95bcc9ca12b30 100644 --- a/src/doc/guide-tasks.md +++ b/src/doc/guide-tasks.md @@ -238,7 +238,7 @@ fn main() { let mut futures = Vec::from_fn(1000, |ind| Future::spawn( proc() { partial_sum(ind) })); let mut final_res = 0f64; - for ft in futures.mut_iter() { + for ft in futures.iter_mut() { final_res += ft.get(); } println!("π^2/6 is not far from : {}", final_res); diff --git a/src/doc/guide.md b/src/doc/guide.md index 43aad880da575..41a0e9abf6c02 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -1319,7 +1319,7 @@ upper bound is exclusive, though, so our loop will print `0` through `9`, not Rust does not have the "C style" `for` loop on purpose. Manually controlling each element of the loop is complicated and error prone, even for experienced C -developers. +developers. We'll talk more about `for` when we cover **iterator**s, later in the Guide. diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 2905b30deeb9a..51e1f64e0065d 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -140,7 +140,7 @@ static MIN_ALIGN: uint = 16; #[cfg(jemalloc)] mod imp { use core::option::{None, Option}; - use core::ptr::{RawPtr, mut_null, null}; + use core::ptr::{RawPtr, null_mut, null}; use core::num::Int; use libc::{c_char, c_int, c_void, size_t}; use super::MIN_ALIGN; @@ -230,7 +230,7 @@ mod imp { pub fn stats_print() { unsafe { - je_malloc_stats_print(None, mut_null(), null()) + je_malloc_stats_print(None, null_mut(), null()) } } } diff --git a/src/liballoc/libc_heap.rs b/src/liballoc/libc_heap.rs index e3fa639929f05..4f6400630fd9c 100644 --- a/src/liballoc/libc_heap.rs +++ b/src/liballoc/libc_heap.rs @@ -12,7 +12,7 @@ //! The global (exchange) heap. use libc::{c_void, size_t, free, malloc, realloc}; -use core::ptr::{RawPtr, mut_null}; +use core::ptr::{RawPtr, null_mut}; /// A wrapper around libc::malloc, aborting on out-of-memory. #[inline] @@ -20,7 +20,7 @@ pub unsafe fn malloc_raw(size: uint) -> *mut u8 { // `malloc(0)` may allocate, but it may also return a null pointer // http://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html if size == 0 { - mut_null() + null_mut() } else { let p = malloc(size as size_t); if p.is_null() { @@ -37,7 +37,7 @@ pub unsafe fn realloc_raw(ptr: *mut u8, size: uint) -> *mut u8 { // http://pubs.opengroup.org/onlinepubs/9699919799/functions/realloc.html if size == 0 { free(ptr as *mut c_void); - mut_null() + null_mut() } else { let p = realloc(ptr as *mut c_void, size as size_t); if p.is_null() { diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index ee3fd6ad0eb0d..d691e01a56276 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -448,7 +448,7 @@ impl TypedArena { #[inline] pub fn with_capacity(capacity: uint) -> TypedArena { unsafe { - let chunk = TypedArenaChunk::::new(ptr::mut_null(), capacity); + let chunk = TypedArenaChunk::::new(ptr::null_mut(), capacity); TypedArena { ptr: Cell::new((*chunk).start() as *const T), end: Cell::new((*chunk).end() as *const T), diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 0a658c51dbd42..11affb9dfd576 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -178,7 +178,7 @@ impl Bitv { // `op` is a bitwise operation, since any bits that should've // been masked were fine to change anyway. `b` is masked to // make sure its unmasked bits do not cause damage. - for (a, (_, b)) in self.storage.mut_iter() + for (a, (_, b)) in self.storage.iter_mut() .zip(other.mask_words(0)) { let w = op(*a, b); if *a != w { @@ -310,7 +310,7 @@ impl Bitv { /// ``` #[inline] pub fn set_all(&mut self) { - for w in self.storage.mut_iter() { *w = !0u; } + for w in self.storage.iter_mut() { *w = !0u; } } /// Flips all bits. @@ -329,7 +329,7 @@ impl Bitv { /// ``` #[inline] pub fn negate(&mut self) { - for w in self.storage.mut_iter() { *w = !*w; } + for w in self.storage.iter_mut() { *w = !*w; } } /// Calculates the union of two bitvectors. This acts like the bitwise `or` @@ -797,7 +797,7 @@ impl Collection for Bitv { impl Mutable for Bitv { #[inline] fn clear(&mut self) { - for w in self.storage.mut_iter() { *w = 0u; } + for w in self.storage.iter_mut() { *w = 0u; } } } @@ -831,7 +831,7 @@ impl Clone for Bitv { fn clone_from(&mut self, source: &Bitv) { self.nbits = source.nbits; self.storage.reserve(source.storage.len()); - for (i, w) in self.storage.mut_iter().enumerate() { *w = source.storage[i]; } + for (i, w) in self.storage.iter_mut().enumerate() { *w = source.storage[i]; } } } diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index cf5c1eed15cd0..45f5e98aa3e83 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -79,7 +79,7 @@ pub struct MoveItems { impl Rawlink { /// Like Option::None for Rawlink fn none() -> Rawlink { - Rawlink{p: ptr::mut_null()} + Rawlink{p: ptr::null_mut()} } /// Like Option::Some for Rawlink @@ -431,7 +431,7 @@ impl DList { /// ``` pub fn insert_when(&mut self, elt: T, f: |&T, &T| -> bool) { { - let mut it = self.mut_iter(); + let mut it = self.iter_mut(); loop { match it.peek_next() { None => break, @@ -451,7 +451,7 @@ impl DList { /// This operation should compute in O(max(N, M)) time. pub fn merge(&mut self, mut other: DList, f: |&T, &T| -> bool) { { - let mut it = self.mut_iter(); + let mut it = self.iter_mut(); loop { let take_a = match (it.peek_next(), other.front()) { (_ , None) => return, @@ -871,7 +871,7 @@ mod tests { check_links(&m); let sum = v.append(u.as_slice()); assert_eq!(sum.len(), m.len()); - for elt in sum.move_iter() { + for elt in sum.into_iter() { assert_eq!(m.pop_front(), Some(elt)) } } @@ -895,7 +895,7 @@ mod tests { check_links(&m); let sum = u.append(v.as_slice()); assert_eq!(sum.len(), m.len()); - for elt in sum.move_iter() { + for elt in sum.into_iter() { assert_eq!(m.pop_front(), Some(elt)) } } @@ -920,7 +920,7 @@ mod tests { m.rotate_backward(); check_links(&m); m.push_front(9); check_links(&m); m.rotate_forward(); check_links(&m); - assert_eq!(vec![3i,9,5,1,2], m.move_iter().collect()); + assert_eq!(vec![3i,9,5,1,2], m.into_iter().collect()); } #[test] @@ -991,16 +991,16 @@ mod tests { fn test_mut_iter() { let mut m = generate_test(); let mut len = m.len(); - for (i, elt) in m.mut_iter().enumerate() { + for (i, elt) in m.iter_mut().enumerate() { assert_eq!(i as int, *elt); len -= 1; } assert_eq!(len, 0); let mut n = DList::new(); - assert!(n.mut_iter().next().is_none()); + assert!(n.iter_mut().next().is_none()); n.push_front(4i); n.push(5); - let mut it = n.mut_iter(); + let mut it = n.iter_mut(); assert_eq!(it.size_hint(), (2, Some(2))); assert!(it.next().is_some()); assert!(it.next().is_some()); @@ -1011,11 +1011,11 @@ mod tests { #[test] fn test_iterator_mut_double_end() { let mut n = DList::new(); - assert!(n.mut_iter().next_back().is_none()); + assert!(n.iter_mut().next_back().is_none()); n.push_front(4i); n.push_front(5); n.push_front(6); - let mut it = n.mut_iter(); + let mut it = n.iter_mut(); assert_eq!(it.size_hint(), (3, Some(3))); assert_eq!(*it.next().unwrap(), 6); assert_eq!(it.size_hint(), (2, Some(2))); @@ -1031,7 +1031,7 @@ mod tests { let mut m = list_from(&[0i,2,4,6,8]); let len = m.len(); { - let mut it = m.mut_iter(); + let mut it = m.iter_mut(); it.insert_next(-2); loop { match it.next() { @@ -1050,7 +1050,7 @@ mod tests { } check_links(&m); assert_eq!(m.len(), 3 + len * 2); - assert_eq!(m.move_iter().collect::>(), vec![-2,0,1,2,3,4,5,6,7,8,9,0,1]); + assert_eq!(m.into_iter().collect::>(), vec![-2,0,1,2,3,4,5,6,7,8,9,0,1]); } #[test] @@ -1061,7 +1061,7 @@ mod tests { m.merge(n, |a, b| a <= b); assert_eq!(m.len(), len); check_links(&m); - let res = m.move_iter().collect::>(); + let res = m.into_iter().collect::>(); assert_eq!(res, vec![-1, 0, 0, 0, 1, 3, 5, 6, 7, 2, 7, 7, 9]); } @@ -1077,19 +1077,19 @@ mod tests { m.push(4); m.insert_ordered(3); check_links(&m); - assert_eq!(vec![2,3,4], m.move_iter().collect::>()); + assert_eq!(vec![2,3,4], m.into_iter().collect::>()); } #[test] fn test_mut_rev_iter() { let mut m = generate_test(); - for (i, elt) in m.mut_iter().rev().enumerate() { + for (i, elt) in m.iter_mut().rev().enumerate() { assert_eq!((6-i) as int, *elt); } let mut n = DList::new(); - assert!(n.mut_iter().rev().next().is_none()); + assert!(n.iter_mut().rev().next().is_none()); n.push_front(4i); - let mut it = n.mut_iter().rev(); + let mut it = n.iter_mut().rev(); assert!(it.next().is_some()); assert!(it.next().is_none()); } @@ -1229,7 +1229,7 @@ mod tests { check_links(&m); let mut i = 0u; - for (a, &b) in m.move_iter().zip(v.iter()) { + for (a, &b) in m.into_iter().zip(v.iter()) { i += 1; assert_eq!(a, b); } @@ -1311,7 +1311,7 @@ mod tests { let v = &[0i, ..128]; let mut m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { - assert!(m.mut_iter().count() == 128); + assert!(m.iter_mut().count() == 128); }) } #[bench] @@ -1327,7 +1327,7 @@ mod tests { let v = &[0i, ..128]; let mut m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { - assert!(m.mut_iter().rev().count() == 128); + assert!(m.iter_mut().rev().count() == 128); }) } } diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index a3dc1d3003104..90ee24eb587a5 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -43,7 +43,7 @@ impl Collection for RingBuf { impl Mutable for RingBuf { /// Clears the `RingBuf`, removing all values. fn clear(&mut self) { - for x in self.elts.mut_iter() { *x = None } + for x in self.elts.iter_mut() { *x = None } self.nelts = 0; self.lo = 0; } @@ -267,11 +267,11 @@ impl RingBuf { /// buf.push(5i); /// buf.push(3); /// buf.push(4); - /// for num in buf.mut_iter() { + /// for num in buf.iter_mut() { /// *num = *num - 2; /// } /// let b: &[_] = &[&mut 3, &mut 1, &mut 2]; - /// assert_eq!(buf.mut_iter().collect::>().as_slice(), b); + /// assert_eq!(buf.iter_mut().collect::>().as_slice(), b); /// ``` pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { let start_index = raw_index(self.lo, self.elts.len(), 0); @@ -283,15 +283,15 @@ impl RingBuf { // start_index to self.elts.len() // and then // 0 to end_index - let (temp, remaining1) = self.elts.mut_split_at(start_index); - let (remaining2, _) = temp.mut_split_at(end_index); + let (temp, remaining1) = self.elts.split_at_mut(start_index); + let (remaining2, _) = temp.split_at_mut(end_index); MutItems { remaining1: remaining1, remaining2: remaining2, nelts: self.nelts } } else { // Items to iterate goes from start_index to end_index: - let (empty, elts) = self.elts.mut_split_at(0); - let remaining1 = elts.mut_slice(start_index, end_index); + let (empty, elts) = self.elts.split_at_mut(0); + let remaining1 = elts.slice_mut(start_index, end_index); MutItems { remaining1: remaining1, remaining2: empty, nelts: self.nelts } @@ -919,7 +919,7 @@ mod tests { #[test] fn test_mut_rev_iter_wrap() { let mut d = RingBuf::with_capacity(3); - assert!(d.mut_iter().rev().next().is_none()); + assert!(d.iter_mut().rev().next().is_none()); d.push(1i); d.push(2); @@ -927,26 +927,26 @@ mod tests { assert_eq!(d.pop_front(), Some(1)); d.push(4); - assert_eq!(d.mut_iter().rev().map(|x| *x).collect::>(), + assert_eq!(d.iter_mut().rev().map(|x| *x).collect::>(), vec!(4, 3, 2)); } #[test] fn test_mut_iter() { let mut d = RingBuf::new(); - assert!(d.mut_iter().next().is_none()); + assert!(d.iter_mut().next().is_none()); for i in range(0u, 3) { d.push_front(i); } - for (i, elt) in d.mut_iter().enumerate() { + for (i, elt) in d.iter_mut().enumerate() { assert_eq!(*elt, 2 - i); *elt = i; } { - let mut it = d.mut_iter(); + let mut it = d.iter_mut(); assert_eq!(*it.next().unwrap(), 0); assert_eq!(*it.next().unwrap(), 1); assert_eq!(*it.next().unwrap(), 2); @@ -957,19 +957,19 @@ mod tests { #[test] fn test_mut_rev_iter() { let mut d = RingBuf::new(); - assert!(d.mut_iter().rev().next().is_none()); + assert!(d.iter_mut().rev().next().is_none()); for i in range(0u, 3) { d.push_front(i); } - for (i, elt) in d.mut_iter().rev().enumerate() { + for (i, elt) in d.iter_mut().rev().enumerate() { assert_eq!(*elt, i); *elt = i; } { - let mut it = d.mut_iter().rev(); + let mut it = d.iter_mut().rev(); assert_eq!(*it.next().unwrap(), 0); assert_eq!(*it.next().unwrap(), 1); assert_eq!(*it.next().unwrap(), 2); diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 36edd913de2f8..f93b5c89127e5 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -77,7 +77,7 @@ //! } //! ``` //! -//! * `.mut_iter()` returns an iterator that allows modifying each value. +//! * `.iter_mut()` returns an iterator that allows modifying each value. //! * Further iterators exist that split, chunk or permute the slice. #![doc(primitive = "slice")] @@ -195,7 +195,7 @@ impl Iterator<(uint, uint)> for ElementSwaps { self.sdir.as_mut_slice().swap(i, j); // Swap the direction of each larger SizeDirection - for x in self.sdir.mut_iter() { + for x in self.sdir.iter_mut() { if x.size > sd.size { x.dir = match x.dir { Pos => Neg, Neg => Pos }; } @@ -606,7 +606,7 @@ impl<'a,T> MutableSliceAllocating<'a, T> for &'a mut [T] { #[inline] fn move_from(self, mut src: Vec, start: uint, end: uint) -> uint { - for (a, b) in self.mut_iter().zip(src.mut_slice(start, end).mut_iter()) { + for (a, b) in self.iter_mut().zip(src.slice_mut(start, end).iter_mut()) { mem::swap(a, b); } cmp::min(self.len(), end-start) @@ -698,7 +698,7 @@ impl<'a, T: Ord> MutableOrdSlice for &'a mut [T] { self.swap(j, i-1); // Step 4: Reverse the (previously) weakly decreasing part - self.mut_slice_from(i).reverse(); + self.slice_from_mut(i).reverse(); true } @@ -719,7 +719,7 @@ impl<'a, T: Ord> MutableOrdSlice for &'a mut [T] { } // Step 2: Reverse the weakly increasing part - self.mut_slice_from(i).reverse(); + self.slice_from_mut(i).reverse(); // Step 3: Find the rightmost element equal to or bigger than the pivot (i-1) let mut j = self.len() - 1; @@ -1685,7 +1685,7 @@ mod tests { fn test_iter_size_hints() { let mut xs = [1i, 2, 5, 10, 11]; assert_eq!(xs.iter().size_hint(), (5, Some(5))); - assert_eq!(xs.mut_iter().size_hint(), (5, Some(5))); + assert_eq!(xs.iter_mut().size_hint(), (5, Some(5))); } #[test] @@ -1702,7 +1702,7 @@ mod tests { #[test] fn test_mut_iterator() { let mut xs = [1i, 2, 3, 4, 5]; - for x in xs.mut_iter() { + for x in xs.iter_mut() { *x += 1; } assert!(xs == [2, 3, 4, 5, 6]) @@ -1724,7 +1724,7 @@ mod tests { #[test] fn test_mut_rev_iterator() { let mut xs = [1u, 2, 3, 4, 5]; - for (i,x) in xs.mut_iter().rev().enumerate() { + for (i,x) in xs.iter_mut().rev().enumerate() { *x += i; } assert!(xs == [5, 5, 5, 5, 5]) @@ -1733,13 +1733,13 @@ mod tests { #[test] fn test_move_iterator() { let xs = vec![1u,2,3,4,5]; - assert_eq!(xs.move_iter().fold(0, |a: uint, b: uint| 10*a + b), 12345); + assert_eq!(xs.into_iter().fold(0, |a: uint, b: uint| 10*a + b), 12345); } #[test] fn test_move_rev_iterator() { let xs = vec![1u,2,3,4,5]; - assert_eq!(xs.move_iter().rev().fold(0, |a: uint, b: uint| 10*a + b), 54321); + assert_eq!(xs.into_iter().rev().fold(0, |a: uint, b: uint| 10*a + b), 54321); } #[test] @@ -1892,7 +1892,7 @@ mod tests { assert!(a == [7i,2,3,4]); let mut a = [1i,2,3,4,5]; let b = vec![5i,6,7,8,9,0]; - assert_eq!(a.mut_slice(2,4).move_from(b,1,6), 2); + assert_eq!(a.slice_mut(2,4).move_from(b,1,6), 2); assert!(a == [1i,2,6,7,5]); } @@ -1911,7 +1911,7 @@ mod tests { #[test] fn test_reverse_part() { let mut values = [1i,2,3,4,5]; - values.mut_slice(1, 4).reverse(); + values.slice_mut(1, 4).reverse(); assert!(values == [1,4,3,2,5]); } @@ -1958,9 +1958,9 @@ mod tests { fn test_bytes_set_memory() { use slice::bytes::MutableByteVector; let mut values = [1u8,2,3,4,5]; - values.mut_slice(0,5).set_memory(0xAB); + values.slice_mut(0,5).set_memory(0xAB); assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]); - values.mut_slice(2,4).set_memory(0xFF); + values.slice_mut(2,4).set_memory(0xFF); assert!(values == [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]); } @@ -1985,14 +1985,14 @@ mod tests { fn test_mut_split_at() { let mut values = [1u8,2,3,4,5]; { - let (left, right) = values.mut_split_at(2); + let (left, right) = values.split_at_mut(2); assert!(left.slice(0, left.len()) == [1, 2]); - for p in left.mut_iter() { + for p in left.iter_mut() { *p += 1; } assert!(right.slice(0, right.len()) == [3, 4, 5]); - for p in right.mut_iter() { + for p in right.iter_mut() { *p += 2; } } @@ -2021,13 +2021,13 @@ mod tests { } assert_eq!(cnt, 5); - for f in v.mut_iter() { + for f in v.iter_mut() { assert!(*f == Foo); cnt += 1; } assert_eq!(cnt, 8); - for f in v.move_iter() { + for f in v.into_iter() { assert!(f == Foo); cnt += 1; } @@ -2113,14 +2113,14 @@ mod tests { #[test] fn test_mut_splitator() { let mut xs = [0i,1,0,2,3,0,0,4,5,0]; - assert_eq!(xs.mut_split(|x| *x == 0).count(), 6); - for slice in xs.mut_split(|x| *x == 0) { + assert_eq!(xs.split_mut(|x| *x == 0).count(), 6); + for slice in xs.split_mut(|x| *x == 0) { slice.reverse(); } assert!(xs == [0,1,0,3,2,0,0,5,4,0]); let mut xs = [0i,1,0,2,3,0,0,4,5,0,6,7]; - for slice in xs.mut_split(|x| *x == 0).take(5) { + for slice in xs.split_mut(|x| *x == 0).take(5) { slice.reverse(); } assert!(xs == [0,1,0,3,2,0,0,5,4,0,6,7]); @@ -2129,7 +2129,7 @@ mod tests { #[test] fn test_mut_splitator_rev() { let mut xs = [1i,2,0,3,4,0,0,5,6,0]; - for slice in xs.mut_split(|x| *x == 0).rev().take(4) { + for slice in xs.split_mut(|x| *x == 0).rev().take(4) { slice.reverse(); } assert!(xs == [1,2,0,4,3,0,0,6,5,0]); @@ -2148,8 +2148,8 @@ mod tests { #[test] fn test_mut_chunks() { let mut v = [0u8, 1, 2, 3, 4, 5, 6]; - for (i, chunk) in v.mut_chunks(3).enumerate() { - for x in chunk.mut_iter() { + for (i, chunk) in v.chunks_mut(3).enumerate() { + for x in chunk.iter_mut() { *x = i as u8; } } @@ -2160,8 +2160,8 @@ mod tests { #[test] fn test_mut_chunks_rev() { let mut v = [0u8, 1, 2, 3, 4, 5, 6]; - for (i, chunk) in v.mut_chunks(3).rev().enumerate() { - for x in chunk.mut_iter() { + for (i, chunk) in v.chunks_mut(3).rev().enumerate() { + for x in chunk.iter_mut() { *x = i as u8; } } @@ -2173,7 +2173,7 @@ mod tests { #[should_fail] fn test_mut_chunks_0() { let mut v = [1i, 2, 3, 4]; - let _it = v.mut_chunks(0); + let _it = v.chunks_mut(0); } #[test] @@ -2207,11 +2207,11 @@ mod tests { #[test] fn test_mut_last() { let mut x = [1i, 2, 3, 4, 5]; - let h = x.mut_last(); + let h = x.last_mut(); assert_eq!(*h.unwrap(), 5); let y: &mut [int] = []; - assert!(y.mut_last().is_none()); + assert!(y.last_mut().is_none()); } } @@ -2248,7 +2248,7 @@ mod bench { b.iter(|| { let mut i = 0i; - for x in v.mut_iter() { + for x in v.iter_mut() { *x = i; i += 1; } @@ -2382,7 +2382,7 @@ mod bench { unsafe { v.set_len(1024); } - for x in v.mut_iter() { + for x in v.iter_mut() { *x = 0i; } v diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index aac34bfd15581..31d3415ef4893 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -163,7 +163,7 @@ impl Clone for SmallIntMap { #[inline] fn clone_from(&mut self, source: &SmallIntMap) { self.v.reserve(source.v.len()); - for (i, w) in self.v.mut_iter().enumerate() { + for (i, w) in self.v.iter_mut().enumerate() { *w = source.v[i].clone(); } } @@ -280,7 +280,7 @@ impl SmallIntMap { /// map.insert(2, "b"); /// map.insert(3, "c"); /// - /// for (key, value) in map.mut_iter() { + /// for (key, value) in map.iter_mut() { /// *value = "x"; /// } /// @@ -292,7 +292,7 @@ impl SmallIntMap { MutEntries { front: 0, back: self.v.len(), - iter: self.v.mut_iter() + iter: self.v.iter_mut() } } @@ -319,7 +319,7 @@ impl SmallIntMap { /// map.insert(2, "b"); /// /// // Not possible with .iter() - /// let vec: Vec<(uint, &str)> = map.move_iter().collect(); + /// let vec: Vec<(uint, &str)> = map.into_iter().collect(); /// /// assert_eq!(vec, vec![(1, "a"), (2, "b"), (3, "c")]); /// ``` @@ -328,7 +328,7 @@ impl SmallIntMap { Enumerate>>> { let values = replace(&mut self.v, vec!()); - values.move_iter().enumerate().filter_map(|(i, v)| { + values.into_iter().enumerate().filter_map(|(i, v)| { v.map(|v| (i, v)) }) } @@ -692,8 +692,8 @@ mod test_map { assert_eq!(m.iter().size_hint(), (0, Some(11))); assert_eq!(m.iter().rev().size_hint(), (0, Some(11))); - assert_eq!(m.mut_iter().size_hint(), (0, Some(11))); - assert_eq!(m.mut_iter().rev().size_hint(), (0, Some(11))); + assert_eq!(m.iter_mut().size_hint(), (0, Some(11))); + assert_eq!(m.iter_mut().rev().size_hint(), (0, Some(11))); } #[test] @@ -706,7 +706,7 @@ mod test_map { assert!(m.insert(6, 10)); assert!(m.insert(10, 11)); - for (k, v) in m.mut_iter() { + for (k, v) in m.iter_mut() { *v += k as int; } @@ -748,7 +748,7 @@ mod test_map { assert!(m.insert(6, 10)); assert!(m.insert(10, 11)); - for (k, v) in m.mut_iter().rev() { + for (k, v) in m.iter_mut().rev() { *v += k as int; } @@ -766,7 +766,7 @@ mod test_map { let mut m = SmallIntMap::new(); m.insert(1, box 2i); let mut called = false; - for (k, v) in m.move_iter() { + for (k, v) in m.into_iter() { assert!(!called); called = true; assert_eq!(k, 1); diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index 0a7c84b5c0c55..73e2d8466546f 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -380,7 +380,7 @@ impl TreeMap { /// map.insert("b", 2i); /// /// // Add 10 until we find "b" - /// for (key, value) in map.mut_iter() { + /// for (key, value) in map.iter_mut() { /// *value += 10; /// if key == &"b" { break } /// } @@ -417,7 +417,7 @@ impl TreeMap { /// map.insert("b", 2i); /// /// // Add 10 until we find "b" - /// for (key, value) in map.mut_rev_iter() { + /// for (key, value) in map.rev_iter_mut() { /// *value += 10; /// if key == &"b" { break } /// } @@ -427,11 +427,11 @@ impl TreeMap { /// assert_eq!(map.find(&"c"), Some(&13)); /// ``` pub fn rev_iter_mut<'a>(&'a mut self) -> RevMutEntries<'a, K, V> { - RevMutEntries{iter: self.mut_iter()} + RevMutEntries{iter: self.iter_mut()} } /// Deprecated: use `into_iter`. - #[depreated = "use into_iter"] + #[deprecated = "use into_iter"] pub fn move_iter(self) -> MoveEntries { self.into_iter() } @@ -448,7 +448,7 @@ impl TreeMap { /// map.insert("b", 2i); /// /// // Not possible with a regular `.iter()` - /// let vec: Vec<(&str, int)> = map.move_iter().collect(); + /// let vec: Vec<(&str, int)> = map.into_iter().collect(); /// assert_eq!(vec, vec![("a", 1), ("b", 2), ("c", 3)]); /// ``` pub fn into_iter(self) -> MoveEntries { @@ -512,7 +512,7 @@ impl TreeMap { /// t.insert("User-Agent", "Curl-Rust/0.1"); /// /// let new_ua = "Safari/156.0"; - /// match t.find_mut_with(|k| "User-Agent".cmp(k)) { + /// match t.find_with_mut(|k| "User-Agent".cmp(k)) { /// Some(x) => *x = new_ua, /// None => fail!(), /// } @@ -649,11 +649,11 @@ impl TreeMap { /// map.insert(6, "c"); /// map.insert(8, "d"); /// - /// assert_eq!(map.mut_lower_bound(&4).next(), Some((&4, &mut "b"))); - /// assert_eq!(map.mut_lower_bound(&5).next(), Some((&6, &mut "c"))); - /// assert_eq!(map.mut_lower_bound(&10).next(), None); + /// assert_eq!(map.lower_bound_mut(&4).next(), Some((&4, &mut "b"))); + /// assert_eq!(map.lower_bound_mut(&5).next(), Some((&6, &mut "c"))); + /// assert_eq!(map.lower_bound_mut(&10).next(), None); /// - /// for (key, value) in map.mut_lower_bound(&4) { + /// for (key, value) in map.lower_bound_mut(&4) { /// *value = "changed"; /// } /// @@ -689,11 +689,11 @@ impl TreeMap { /// map.insert(6, "c"); /// map.insert(8, "d"); /// - /// assert_eq!(map.mut_upper_bound(&4).next(), Some((&6, &mut "c"))); - /// assert_eq!(map.mut_upper_bound(&5).next(), Some((&6, &mut "c"))); - /// assert_eq!(map.mut_upper_bound(&10).next(), None); + /// assert_eq!(map.upper_bound_mut(&4).next(), Some((&6, &mut "c"))); + /// assert_eq!(map.upper_bound_mut(&5).next(), Some((&6, &mut "c"))); + /// assert_eq!(map.upper_bound_mut(&10).next(), None); /// - /// for (key, value) in map.mut_upper_bound(&4) { + /// for (key, value) in map.upper_bound_mut(&4) { /// *value = "changed"; /// } /// @@ -919,7 +919,7 @@ fn deref_mut(x: &mut Option>>) let n: &mut TreeNode = &mut **n; n as *mut TreeNode } - None => ptr::mut_null() + None => ptr::null_mut() } } @@ -1220,7 +1220,7 @@ impl TreeSet { /// let set: TreeSet = [1i, 4, 3, 5, 2].iter().map(|&x| x).collect(); /// /// // Not possible with a regular `.iter()` - /// let v: Vec = set.move_iter().collect(); + /// let v: Vec = set.into_iter().collect(); /// assert_eq!(v, vec![1, 2, 3, 4, 5]); /// ``` #[inline] @@ -1583,7 +1583,7 @@ fn remove(node: &mut Option>>, fn heir_swap(node: &mut Box>, child: &mut Option>>) { // *could* be done without recursion, but it won't borrow check - for x in child.mut_iter() { + for x in child.iter_mut() { if x.right.is_some() { heir_swap(node, &mut x.right); } else { @@ -1639,18 +1639,18 @@ fn remove(node: &mut Option>>, if right_level > save.level { let save_level = save.level; - for x in save.right.mut_iter() { x.level = save_level } + for x in save.right.iter_mut() { x.level = save_level } } skew(save); - for right in save.right.mut_iter() { + for right in save.right.iter_mut() { skew(right); - for x in right.right.mut_iter() { skew(x) } + for x in right.right.iter_mut() { skew(x) } } split(save); - for x in save.right.mut_iter() { split(x) } + for x in save.right.iter_mut() { split(x) } } return ret; @@ -1780,7 +1780,7 @@ mod test_treemap { assert!(m.insert("t2", 8)); assert!(m.insert("t5", 14)); let new = 100; - match m.find_mut_with(|k| "t5".cmp(k)) { + match m.find_with_mut(|k| "t5".cmp(k)) { None => fail!(), Some(x) => *x = new } assert_eq!(m.find_with(|k| "t5".cmp(k)), Some(&new)); @@ -2006,7 +2006,7 @@ mod test_treemap { assert!(m.insert(i, 100 * i)); } - for (i, (&k, v)) in m.mut_iter().enumerate() { + for (i, (&k, v)) in m.iter_mut().enumerate() { *v += k * 10 + i; // 000 + 00 + 0, 100 + 10 + 1, ... } @@ -2021,7 +2021,7 @@ mod test_treemap { assert!(m.insert(i, 100 * i)); } - for (i, (&k, v)) in m.mut_rev_iter().enumerate() { + for (i, (&k, v)) in m.rev_iter_mut().enumerate() { *v += k * 10 + (9 - i); // 900 + 90 + (9 - 0), 800 + 80 + (9 - 1), ... } @@ -2040,23 +2040,23 @@ mod test_treemap { } for i in range(1i, 199) { - let mut lb_it = m_lower.mut_lower_bound(&i); + let mut lb_it = m_lower.lower_bound_mut(&i); let (&k, v) = lb_it.next().unwrap(); let lb = i + i % 2; assert_eq!(lb, k); *v -= k; } for i in range(0i, 198) { - let mut ub_it = m_upper.mut_upper_bound(&i); + let mut ub_it = m_upper.upper_bound_mut(&i); let (&k, v) = ub_it.next().unwrap(); let ub = i + 2 - i % 2; assert_eq!(ub, k); *v -= k; } - assert!(m_lower.mut_lower_bound(&199).next().is_none()); + assert!(m_lower.lower_bound_mut(&199).next().is_none()); - assert!(m_upper.mut_upper_bound(&198).next().is_none()); + assert!(m_upper.upper_bound_mut(&198).next().is_none()); assert!(m_lower.iter().all(|(_, &x)| x == 0)); assert!(m_upper.iter().all(|(_, &x)| x == 0)); @@ -2065,7 +2065,7 @@ mod test_treemap { #[test] fn test_keys() { let vec = vec![(1i, 'a'), (2i, 'b'), (3i, 'c')]; - let map = vec.move_iter().collect::>(); + let map = vec.into_iter().collect::>(); let keys = map.keys().map(|&k| k).collect::>(); assert_eq!(keys.len(), 3); assert!(keys.contains(&1)); @@ -2076,7 +2076,7 @@ mod test_treemap { #[test] fn test_values() { let vec = vec![(1i, 'a'), (2i, 'b'), (3i, 'c')]; - let map = vec.move_iter().collect::>(); + let map = vec.into_iter().collect::>(); let values = map.values().map(|&v| v).collect::>(); assert_eq!(values.len(), 3); assert!(values.contains(&'a')); @@ -2402,7 +2402,7 @@ mod test_set { let s: TreeSet = range(0i, 5).collect(); let mut n = 0; - for x in s.move_iter() { + for x in s.into_iter() { assert_eq!(x, n); n += 1; } @@ -2410,9 +2410,9 @@ mod test_set { #[test] fn test_move_iter_size_hint() { - let s: TreeSet = vec!(0i, 1).move_iter().collect(); + let s: TreeSet = vec!(0i, 1).into_iter().collect(); - let mut it = s.move_iter(); + let mut it = s.into_iter(); assert_eq!(it.size_hint(), (2, Some(2))); assert!(it.next() != None); diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index f447bcba917a8..99e5899dc1567 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -282,7 +282,7 @@ impl TrieMap { /// use std::collections::TrieMap; /// let mut map: TrieMap = [(1, 2), (2, 4), (3, 6)].iter().map(|&x| x).collect(); /// - /// for (key, value) in map.mut_iter() { + /// for (key, value) in map.iter_mut() { /// *value = -(key as int); /// } /// @@ -292,7 +292,7 @@ impl TrieMap { /// ``` pub fn iter_mut<'a>(&'a mut self) -> MutEntries<'a, T> { let mut iter = unsafe {MutEntries::new()}; - iter.stack[0] = self.root.children.mut_iter(); + iter.stack[0] = self.root.children.iter_mut(); iter.length = 1; iter.remaining_min = self.length; iter.remaining_max = self.length; @@ -453,11 +453,11 @@ impl TrieMap { /// use std::collections::TrieMap; /// let mut map: TrieMap<&str> = [(2, "a"), (4, "b"), (6, "c")].iter().map(|&x| x).collect(); /// - /// assert_eq!(map.mut_lower_bound(4).next(), Some((4, &mut "b"))); - /// assert_eq!(map.mut_lower_bound(5).next(), Some((6, &mut "c"))); - /// assert_eq!(map.mut_lower_bound(10).next(), None); + /// assert_eq!(map.lower_bound_mut(4).next(), Some((4, &mut "b"))); + /// assert_eq!(map.lower_bound_mut(5).next(), Some((6, &mut "c"))); + /// assert_eq!(map.lower_bound_mut(10).next(), None); /// - /// for (key, value) in map.mut_lower_bound(4) { + /// for (key, value) in map.lower_bound_mut(4) { /// *value = "changed"; /// } /// @@ -484,11 +484,11 @@ impl TrieMap { /// use std::collections::TrieMap; /// let mut map: TrieMap<&str> = [(2, "a"), (4, "b"), (6, "c")].iter().map(|&x| x).collect(); /// - /// assert_eq!(map.mut_upper_bound(4).next(), Some((6, &mut "c"))); - /// assert_eq!(map.mut_upper_bound(5).next(), Some((6, &mut "c"))); - /// assert_eq!(map.mut_upper_bound(10).next(), None); + /// assert_eq!(map.upper_bound_mut(4).next(), Some((6, &mut "c"))); + /// assert_eq!(map.upper_bound_mut(5).next(), Some((6, &mut "c"))); + /// assert_eq!(map.upper_bound_mut(10).next(), None); /// - /// for (key, value) in map.mut_upper_bound(4) { + /// for (key, value) in map.upper_bound_mut(4) { /// *value = "changed"; /// } /// @@ -1195,7 +1195,7 @@ mod test_map { #[test] fn test_keys() { let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; - let map = vec.move_iter().collect::>(); + let map = vec.into_iter().collect::>(); let keys = map.keys().collect::>(); assert_eq!(keys.len(), 3); assert!(keys.contains(&1)); @@ -1206,7 +1206,7 @@ mod test_map { #[test] fn test_values() { let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; - let map = vec.move_iter().collect::>(); + let map = vec.into_iter().collect::>(); let values = map.values().map(|&v| v).collect::>(); assert_eq!(values.len(), 3); assert!(values.contains(&'a')); @@ -1239,7 +1239,7 @@ mod test_map { #[test] fn test_mut_iter() { let mut empty_map : TrieMap = TrieMap::new(); - assert!(empty_map.mut_iter().next().is_none()); + assert!(empty_map.iter_mut().next().is_none()); let first = uint::MAX - 10000; let last = uint::MAX; @@ -1250,7 +1250,7 @@ mod test_map { } let mut i = 0; - for (k, v) in map.mut_iter() { + for (k, v) in map.iter_mut() { assert_eq!(k, first + i); *v -= k / 2; i += 1; @@ -1316,7 +1316,7 @@ mod test_map { } for i in range(0u, 199) { - let mut lb_it = m_lower.mut_lower_bound(i); + let mut lb_it = m_lower.lower_bound_mut(i); let (k, v) = lb_it.next().unwrap(); let lb = i + i % 2; assert_eq!(lb, k); @@ -1324,15 +1324,15 @@ mod test_map { } for i in range(0u, 198) { - let mut ub_it = m_upper.mut_upper_bound(i); + let mut ub_it = m_upper.upper_bound_mut(i); let (k, v) = ub_it.next().unwrap(); let ub = i + 2 - i % 2; assert_eq!(ub, k); *v -= k; } - assert!(m_lower.mut_lower_bound(199).next().is_none()); - assert!(m_upper.mut_upper_bound(198).next().is_none()); + assert!(m_lower.lower_bound_mut(199).next().is_none()); + assert!(m_upper.upper_bound_mut(198).next().is_none()); assert!(m_lower.iter().all(|(_, &x)| x == 0)); assert!(m_upper.iter().all(|(_, &x)| x == 0)); diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 3557390ef9651..f570573262a41 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -181,7 +181,7 @@ impl Vec { let mut xs = Vec::with_capacity(length); while xs.len < length { let len = xs.len; - ptr::write(xs.as_mut_slice().unsafe_mut_ref(len), op(len)); + ptr::write(xs.as_mut_slice().unsafe_mut(len), op(len)); xs.len += 1; } xs @@ -252,7 +252,7 @@ impl Vec { let mut lefts = Vec::new(); let mut rights = Vec::new(); - for elt in self.move_iter() { + for elt in self.into_iter() { if f(&elt) { lefts.push(elt); } else { @@ -311,7 +311,7 @@ impl Vec { let mut xs = Vec::with_capacity(length); while xs.len < length { let len = xs.len; - ptr::write(xs.as_mut_slice().unsafe_mut_ref(len), + ptr::write(xs.as_mut_slice().unsafe_mut(len), value.clone()); xs.len += 1; } @@ -343,7 +343,7 @@ impl Vec { // during the loop can prevent this optimisation. unsafe { ptr::write( - self.as_mut_slice().unsafe_mut_ref(len), + self.as_mut_slice().unsafe_mut(len), other.unsafe_get(i).clone()); self.set_len(len + 1); } @@ -437,7 +437,7 @@ impl Clone for Vec { } // reuse the contained values' allocations/resources. - for (place, thing) in self.mut_iter().zip(other.iter()) { + for (place, thing) in self.iter_mut().zip(other.iter()) { place.clone_from(thing) } @@ -738,7 +738,7 @@ impl Vec { /// /// ``` /// let v = vec!["a".to_string(), "b".to_string()]; - /// for s in v.move_iter() { + /// for s in v.into_iter() { /// // s has type String, not &String /// println!("{}", s); /// } @@ -841,13 +841,13 @@ impl Vec { /// /// ``` /// let mut vec = vec![1i, 2, 3]; - /// for num in vec.mut_iter() { + /// for num in vec.iter_mut() { /// *num = 0; /// } /// ``` #[inline] pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a,T> { - self.as_mut_slice().mut_iter() + self.as_mut_slice().iter_mut() } /// Sorts the vector, in place, using `compare` to compare elements. @@ -951,12 +951,12 @@ impl Vec { /// /// ``` /// let mut vec = vec![1i, 2, 3]; - /// *vec.mut_last().unwrap() = 4; + /// *vec.last_mut().unwrap() = 4; /// assert_eq!(vec, vec![1i, 2, 4]); /// ``` #[inline] pub fn last_mut<'a>(&'a mut self) -> Option<&'a mut T> { - self.as_mut_slice().mut_last() + self.as_mut_slice().last_mut() } /// Removes an element from anywhere in the vector and return it, replacing @@ -1119,7 +1119,7 @@ impl Vec { /// ``` #[inline] pub fn push_all_move(&mut self, other: Vec) { - self.extend(other.move_iter()); + self.extend(other.into_iter()); } /// Deprecated: use `slice_mut`. @@ -1140,12 +1140,12 @@ impl Vec { /// /// ``` /// let mut vec = vec![1i, 2, 3, 4]; - /// assert!(vec.mut_slice(0, 2) == [1, 2]); + /// assert!(vec.slice_mut(0, 2) == [1, 2]); /// ``` #[inline] pub fn slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] { - self.as_mut_slice().mut_slice(start, end) + self.as_mut_slice().slice_mut(start, end) } /// Deprecated: use "slice_from_mut". @@ -1164,11 +1164,11 @@ impl Vec { /// /// ``` /// let mut vec = vec![1i, 2, 3, 4]; - /// assert!(vec.mut_slice_from(2) == [3, 4]); + /// assert!(vec.slice_from_mut(2) == [3, 4]); /// ``` #[inline] pub fn slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T] { - self.as_mut_slice().mut_slice_from(start) + self.as_mut_slice().slice_from_mut(start) } /// Deprecated: use `slice_to_mut`. @@ -1187,11 +1187,11 @@ impl Vec { /// /// ``` /// let mut vec = vec![1i, 2, 3, 4]; - /// assert!(vec.mut_slice_to(2) == [1, 2]); + /// assert!(vec.slice_to_mut(2) == [1, 2]); /// ``` #[inline] pub fn slice_to_mut<'a>(&'a mut self, end: uint) -> &'a mut [T] { - self.as_mut_slice().mut_slice_to(end) + self.as_mut_slice().slice_to_mut(end) } /// Deprecated: use `split_at_mut`. @@ -1217,26 +1217,26 @@ impl Vec { /// /// // scoped to restrict the lifetime of the borrows /// { - /// let (left, right) = vec.mut_split_at(0); + /// let (left, right) = vec.split_at_mut(0); /// assert!(left == &mut []); /// assert!(right == &mut [1, 2, 3, 4, 5, 6]); /// } /// /// { - /// let (left, right) = vec.mut_split_at(2); + /// let (left, right) = vec.split_at_mut(2); /// assert!(left == &mut [1, 2]); /// assert!(right == &mut [3, 4, 5, 6]); /// } /// /// { - /// let (left, right) = vec.mut_split_at(6); + /// let (left, right) = vec.split_at_mut(6); /// assert!(left == &mut [1, 2, 3, 4, 5, 6]); /// assert!(right == &mut []); /// } /// ``` #[inline] pub fn split_at_mut<'a>(&'a mut self, mid: uint) -> (&'a mut [T], &'a mut [T]) { - self.as_mut_slice().mut_split_at(mid) + self.as_mut_slice().split_at_mut(mid) } /// Reverses the order of elements in a vector, in place. @@ -2111,9 +2111,9 @@ mod tests { fn test_mut_slice_from() { let mut values = Vec::from_slice([1u8,2,3,4,5]); { - let slice = values.mut_slice_from(2); + let slice = values.slice_from_mut(2); assert!(slice == [3, 4, 5]); - for p in slice.mut_iter() { + for p in slice.iter_mut() { *p += 2; } } @@ -2125,9 +2125,9 @@ mod tests { fn test_mut_slice_to() { let mut values = Vec::from_slice([1u8,2,3,4,5]); { - let slice = values.mut_slice_to(2); + let slice = values.slice_to_mut(2); assert!(slice == [1, 2]); - for p in slice.mut_iter() { + for p in slice.iter_mut() { *p += 1; } } @@ -2139,14 +2139,14 @@ mod tests { fn test_mut_split_at() { let mut values = Vec::from_slice([1u8,2,3,4,5]); { - let (left, right) = values.mut_split_at(2); + let (left, right) = values.split_at_mut(2); assert!(left.slice(0, left.len()) == [1, 2]); - for p in left.mut_iter() { + for p in left.iter_mut() { *p += 1; } assert!(right.slice(0, right.len()) == [3, 4, 5]); - for p in right.mut_iter() { + for p in right.iter_mut() { *p += 2; } } @@ -2223,15 +2223,15 @@ mod tests { for &() in v.iter() {} - assert_eq!(v.mut_iter().count(), 2); + assert_eq!(v.iter_mut().count(), 2); v.push(()); - assert_eq!(v.mut_iter().count(), 3); + assert_eq!(v.iter_mut().count(), 3); v.push(()); - assert_eq!(v.mut_iter().count(), 4); + assert_eq!(v.iter_mut().count(), 4); - for &() in v.mut_iter() {} + for &() in v.iter_mut() {} unsafe { v.set_len(0); } - assert_eq!(v.mut_iter().count(), 0); + assert_eq!(v.iter_mut().count(), 0); } #[test] @@ -2339,7 +2339,7 @@ mod tests { vec.push(1); vec.push(2); let ptr = vec.as_ptr(); - vec = vec.move_iter().unwrap(); + vec = vec.into_iter().unwrap(); assert_eq!(vec.as_ptr(), ptr); assert_eq!(vec.capacity(), 7); assert_eq!(vec.len(), 0); @@ -2495,7 +2495,7 @@ mod tests { b.bytes = src_len as u64; b.iter(|| { - let dst: Vec = FromIterator::from_iter(src.clone().move_iter()); + let dst: Vec = FromIterator::from_iter(src.clone().into_iter()); assert_eq!(dst.len(), src_len); assert!(dst.iter().enumerate().all(|(i, x)| i == *x)); }); @@ -2529,7 +2529,7 @@ mod tests { b.iter(|| { let mut dst = dst.clone(); - dst.extend(src.clone().move_iter()); + dst.extend(src.clone().into_iter()); assert_eq!(dst.len(), dst_len + src_len); assert!(dst.iter().enumerate().all(|(i, x)| i == *x)); }); diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 3a07e43e50993..fcc794fd0d10c 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -203,7 +203,7 @@ pub fn float_to_str_bytes_common( _ => () } - buf.mut_slice_to(end).reverse(); + buf.slice_to_mut(end).reverse(); // Remember start of the fractional digits. // Points one beyond end of buf if none get generated, @@ -342,7 +342,7 @@ pub fn float_to_str_bytes_common( impl<'a> fmt::FormatWriter for Filler<'a> { fn write(&mut self, bytes: &[u8]) -> fmt::Result { - slice::bytes::copy_memory(self.buf.mut_slice_from(*self.end), + slice::bytes::copy_memory(self.buf.slice_from_mut(*self.end), bytes); *self.end += bytes.len(); Ok(()) diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index f41d02070c9ee..7bab59960b0fe 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -420,7 +420,7 @@ impl<'a> Formatter<'a> { // Writes the sign if it exists, and then the prefix if it was requested let write_prefix = |f: &mut Formatter| { - for c in sign.move_iter() { + for c in sign.into_iter() { let mut b = [0, ..4]; let n = c.encode_utf8(b).unwrap_or(0); try!(f.buf.write(b.slice_to(n))); diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 21cbafdc60538..568745d70b399 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -43,7 +43,7 @@ trait GenericRadix { if is_positive { // Accumulate each digit of the number from the least significant // to the most significant figure. - for byte in buf.mut_iter().rev() { + for byte in buf.iter_mut().rev() { let n = x % base; // Get the current place value. x = x / base; // Deaccumulate the number. *byte = self.digit(cast(n).unwrap()); // Store the digit in the buffer. @@ -52,7 +52,7 @@ trait GenericRadix { } } else { // Do the same as above, but accounting for two's complement. - for byte in buf.mut_iter().rev() { + for byte in buf.iter_mut().rev() { let n = -(x % base); // Get the current place value. x = x / base; // Deaccumulate the number. *byte = self.digit(cast(n).unwrap()); // Store the digit in the buffer. diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index cf977a6ebe603..6bee0573facc3 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -377,7 +377,7 @@ pub trait Iterator { /// sum /// } /// let x = vec![1i,2,3,7,8,9]; - /// assert_eq!(process(x.move_iter()), 1006); + /// assert_eq!(process(x.into_iter()), 1006); /// ``` #[inline] fn fuse(self) -> Fuse { @@ -1682,7 +1682,7 @@ impl<'a, A, T: Iterator, B, U: Iterator> Iterator for FlatMap<'a, A, T, #[inline] fn next(&mut self) -> Option { loop { - for inner in self.frontiter.mut_iter() { + for inner in self.frontiter.iter_mut() { for x in *inner { return Some(x) } @@ -1713,7 +1713,7 @@ impl<'a, #[inline] fn next_back(&mut self) -> Option { loop { - for inner in self.backiter.mut_iter() { + for inner in self.backiter.iter_mut() { match inner.next_back() { None => (), y => return y diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 42416a640bf65..b76c92140fda6 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -124,7 +124,7 @@ pub fn mut_null() -> *mut T { null_mut() } /// ``` /// use std::ptr; /// -/// let p: *mut int = ptr::mut_null(); +/// let p: *mut int = ptr::null_mut(); /// assert!(p.is_null()); /// ``` #[inline] @@ -327,7 +327,7 @@ impl RawPtr for *const T { impl RawPtr for *mut T { #[inline] - fn null() -> *mut T { mut_null() } + fn null() -> *mut T { null_mut() } #[inline] fn is_null(&self) -> bool { *self == RawPtr::null() } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 05b0c1e4f70ba..65ad7bb1753b4 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -583,7 +583,7 @@ pub trait MutableSlice<'a, T> { * ```ignore * if self.len() == 0 { return None; } * let head = &mut self[0]; - * *self = self.mut_slice_from(1); + * *self = self.slice_from_mut(1); * Some(head) * ``` * @@ -602,7 +602,7 @@ pub trait MutableSlice<'a, T> { * ```ignore * if self.len() == 0 { return None; } * let tail = &mut self[self.len() - 1]; - * *self = self.mut_slice_to(self.len() - 1); + * *self = self.slice_to_mut(self.len() - 1); * Some(tail) * ``` * @@ -650,19 +650,19 @@ pub trait MutableSlice<'a, T> { /// /// // scoped to restrict the lifetime of the borrows /// { - /// let (left, right) = v.mut_split_at(0); + /// let (left, right) = v.split_at_mut(0); /// assert!(left == &mut []); /// assert!(right == &mut [1i, 2, 3, 4, 5, 6]); /// } /// /// { - /// let (left, right) = v.mut_split_at(2); + /// let (left, right) = v.split_at_mut(2); /// assert!(left == &mut [1i, 2]); /// assert!(right == &mut [3i, 4, 5, 6]); /// } /// /// { - /// let (left, right) = v.mut_split_at(6); + /// let (left, right) = v.split_at_mut(6); /// assert!(left == &mut [1i, 2, 3, 4, 5, 6]); /// assert!(right == &mut []); /// } @@ -768,12 +768,12 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { #[inline] fn slice_from_mut(self, start: uint) -> &'a mut [T] { let len = self.len(); - self.mut_slice(start, len) + self.slice_mut(start, len) } #[inline] fn slice_to_mut(self, end: uint) -> &'a mut [T] { - self.mut_slice(0, end) + self.slice_mut(0, end) } #[inline] @@ -781,7 +781,7 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { unsafe { let len = self.len(); let self2: &'a mut [T] = mem::transmute_copy(&self); - (self.mut_slice(0, mid), self2.mut_slice(mid, len)) + (self.slice_mut(0, mid), self2.slice_mut(mid, len)) } } @@ -861,8 +861,8 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { while i < ln / 2 { // Unsafe swap to avoid the bounds check in safe swap. unsafe { - let pa: *mut T = self.unsafe_mut_ref(i); - let pb: *mut T = self.unsafe_mut_ref(ln - i - 1); + let pa: *mut T = self.unsafe_mut(i); + let pb: *mut T = self.unsafe_mut(ln - i - 1); ptr::swap(pa, pb); } i += 1; @@ -881,7 +881,7 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { #[inline] unsafe fn unsafe_set(self, index: uint, val: T) { - *self.unsafe_mut_ref(index) = val; + *self.unsafe_mut(index) = val; } #[inline] @@ -1018,7 +1018,7 @@ pub trait MutableCloneableSlice { impl<'a, T:Clone> MutableCloneableSlice for &'a mut [T] { #[inline] fn clone_from_slice(self, src: &[T]) -> uint { - for (a, b) in self.mut_iter().zip(src.iter()) { + for (a, b) in self.iter_mut().zip(src.iter()) { a.clone_from(b); } cmp::min(self.len(), src.len()) @@ -1274,14 +1274,14 @@ impl<'a, T> Iterator<&'a mut [T]> for MutSplits<'a, T> { self.finished = true; let tmp = mem::replace(&mut self.v, &mut []); let len = tmp.len(); - let (head, tail) = tmp.mut_split_at(len); + let (head, tail) = tmp.split_at_mut(len); self.v = tail; Some(head) } Some(idx) => { let tmp = mem::replace(&mut self.v, &mut []); - let (head, tail) = tmp.mut_split_at(idx); - self.v = tail.mut_slice_from(1); + let (head, tail) = tmp.split_at_mut(idx); + self.v = tail.slice_from_mut(1); Some(head) } } @@ -1314,9 +1314,9 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutSplits<'a, T> { } Some(idx) => { let tmp = mem::replace(&mut self.v, &mut []); - let (head, tail) = tmp.mut_split_at(idx); + let (head, tail) = tmp.split_at_mut(idx); self.v = head; - Some(tail.mut_slice_from(1)) + Some(tail.slice_from_mut(1)) } } } @@ -1483,7 +1483,7 @@ impl<'a, T> Iterator<&'a mut [T]> for MutChunks<'a, T> { } else { let sz = cmp::min(self.v.len(), self.chunk_size); let tmp = mem::replace(&mut self.v, &mut []); - let (head, tail) = tmp.mut_split_at(sz); + let (head, tail) = tmp.split_at_mut(sz); self.v = tail; Some(head) } @@ -1512,7 +1512,7 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutChunks<'a, T> { let sz = if remainder != 0 { remainder } else { self.chunk_size }; let tmp = mem::replace(&mut self.v, &mut []); let tmp_len = tmp.len(); - let (head, tail) = tmp.mut_split_at(tmp_len - sz); + let (head, tail) = tmp.split_at_mut(tmp_len - sz); self.v = head; Some(tail) } diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index 9b703a18caee9..1aaea19216264 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -794,7 +794,7 @@ fn test_range_step_inclusive() { #[test] fn test_reverse() { let mut ys = [1i, 2, 3, 4, 5]; - ys.mut_iter().reverse_(); + ys.iter_mut().reverse_(); assert!(ys == [5, 4, 3, 2, 1]); } diff --git a/src/libcoretest/option.rs b/src/libcoretest/option.rs index 6e5bf6e8f2dac..ed7fc3aa4f236 100644 --- a/src/libcoretest/option.rs +++ b/src/libcoretest/option.rs @@ -213,7 +213,7 @@ fn test_mut_iter() { let mut x = Some(val); { - let mut it = x.mut_iter(); + let mut it = x.iter_mut(); assert_eq!(it.size_hint(), (1, Some(1))); @@ -275,7 +275,7 @@ fn test_collect() { // test that it does not take more elements than it needs let mut functions = [|| Some(()), || None, || fail!()]; - let v: Option> = collect(functions.mut_iter().map(|f| (*f)())); + let v: Option> = collect(functions.iter_mut().map(|f| (*f)())); assert!(v == None); } diff --git a/src/libcoretest/result.rs b/src/libcoretest/result.rs index dbc393967d3e5..b45ac6a993efb 100644 --- a/src/libcoretest/result.rs +++ b/src/libcoretest/result.rs @@ -84,7 +84,7 @@ fn test_collect() { // test that it does not take more elements than it needs let mut functions = [|| Ok(()), || Err(1i), || fail!()]; - let v: Result, int> = collect(functions.mut_iter().map(|f| (*f)())); + let v: Result, int> = collect(functions.iter_mut().map(|f| (*f)())); assert!(v == Err(1)); } @@ -104,7 +104,7 @@ fn test_fold() { // test that it does not take more elements than it needs let mut functions = [|| Ok(()), || Err(1i), || fail!()]; - assert_eq!(fold_(functions.mut_iter() + assert_eq!(fold_(functions.iter_mut() .map(|f| (*f)())), Err(1)); } diff --git a/src/libglob/lib.rs b/src/libglob/lib.rs index 0cc9bb1a8aa6c..337919b5c6864 100644 --- a/src/libglob/lib.rs +++ b/src/libglob/lib.rs @@ -190,7 +190,7 @@ fn list_dir_sorted(path: &Path) -> Option> { match fs::readdir(path) { Ok(mut children) => { children.sort_by(|p1, p2| p2.filename().cmp(&p1.filename())); - Some(children.move_iter().collect()) + Some(children.into_iter().collect()) } Err(..) => None } @@ -505,7 +505,7 @@ fn fill_todo(todo: &mut Vec<(Path, uint)>, patterns: &[Pattern], idx: uint, path None => { match list_dir_sorted(path) { Some(entries) => { - todo.extend(entries.move_iter().map(|x|(x, idx))); + todo.extend(entries.into_iter().map(|x|(x, idx))); // Matching the special directory entries . and .. that refer to // the current and parent directory respectively requires that diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index ea298f5e05f71..19f58a210d00b 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -588,12 +588,12 @@ mod tests { fn to_opt_strs(self) -> Vec> { match self { UnlabelledNodes(len) - => Vec::from_elem(len, None).move_iter().collect(), + => Vec::from_elem(len, None).into_iter().collect(), AllNodesLabelled(lbls) - => lbls.move_iter().map( + => lbls.into_iter().map( |l|Some(l)).collect(), SomeNodesLabelled(lbls) - => lbls.move_iter().collect(), + => lbls.into_iter().collect(), } } } diff --git a/src/libgreen/basic.rs b/src/libgreen/basic.rs index e48786f33745f..27c71cb3e7c7e 100644 --- a/src/libgreen/basic.rs +++ b/src/libgreen/basic.rs @@ -53,7 +53,7 @@ impl BasicLoop { /// Process everything in the work queue (continually) fn work(&mut self) { while self.work.len() > 0 { - for work in mem::replace(&mut self.work, vec![]).move_iter() { + for work in mem::replace(&mut self.work, vec![]).into_iter() { work(); } } @@ -63,7 +63,7 @@ impl BasicLoop { let messages = unsafe { mem::replace(&mut *self.messages.lock(), Vec::new()) }; - for message in messages.move_iter() { + for message in messages.into_iter() { self.message(message); } } @@ -71,7 +71,7 @@ impl BasicLoop { fn message(&mut self, message: Message) { match message { RunRemote(i) => { - match self.remotes.mut_iter().find(|& &(id, _)| id == i) { + match self.remotes.iter_mut().find(|& &(id, _)| id == i) { Some(&(_, ref mut f)) => f.call(), None => unreachable!() } diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index cc77d151231e8..00f246ea05eec 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -435,7 +435,7 @@ impl SchedPool { // Now that we've got all our work queues, create one scheduler per // queue, spawn the scheduler into a thread, and be sure to keep a // handle to the scheduler and the thread to keep them alive. - for worker in workers.move_iter() { + for worker in workers.into_iter() { rtdebug!("inserting a regular scheduler"); let mut sched = box Scheduler::new(pool.id, @@ -493,7 +493,7 @@ impl SchedPool { // Tell all existing schedulers about this new scheduler so they can all // steal work from it - for handle in self.handles.mut_iter() { + for handle in self.handles.iter_mut() { handle.send(NewNeighbor(stealer.clone())); } @@ -535,10 +535,10 @@ impl SchedPool { } // Now that everyone's gone, tell everything to shut down. - for mut handle in replace(&mut self.handles, vec![]).move_iter() { + for mut handle in replace(&mut self.handles, vec![]).into_iter() { handle.send(Shutdown); } - for thread in replace(&mut self.threads, vec![]).move_iter() { + for thread in replace(&mut self.threads, vec![]).into_iter() { thread.join(); } } diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index bc1d877dc547b..3c49e1c40d63c 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -355,7 +355,7 @@ pub fn readdir(p: &CString) -> IoResult> { let root = unsafe { CString::new(root.as_ptr(), false) }; let root = Path::new(root); - dirs.move_iter().filter(|path| { + dirs.into_iter().filter(|path| { path.as_vec() != b"." && path.as_vec() != b".." }).map(|path| root.join(path).to_c_str()).collect() } diff --git a/src/libnative/io/file_windows.rs b/src/libnative/io/file_windows.rs index adc97c6bede70..6aa965948fd70 100644 --- a/src/libnative/io/file_windows.rs +++ b/src/libnative/io/file_windows.rs @@ -52,7 +52,7 @@ impl FileDesc { let ret = unsafe { libc::ReadFile(self.handle(), buf.as_ptr() as libc::LPVOID, buf.len() as libc::DWORD, &mut read, - ptr::mut_null()) + ptr::null_mut()) }; if ret != 0 { Ok(read as uint) @@ -68,7 +68,7 @@ impl FileDesc { let ret = unsafe { libc::WriteFile(self.handle(), cur as libc::LPVOID, remaining as libc::DWORD, &mut amt, - ptr::mut_null()) + ptr::null_mut()) }; if ret != 0 { remaining -= amt as uint; @@ -313,10 +313,10 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess) libc::CreateFileW(path.as_ptr(), dwDesiredAccess, dwShareMode, - ptr::mut_null(), + ptr::null_mut(), dwCreationDisposition, dwFlagsAndAttributes, - ptr::mut_null()) + ptr::null_mut()) }; if handle == libc::INVALID_HANDLE_VALUE { Err(super::last_error()) @@ -337,7 +337,7 @@ pub fn mkdir(p: &CString, _mode: uint) -> IoResult<()> { let p = try!(to_utf16(p)); super::mkerr_winbool(unsafe { // FIXME: turn mode into something useful? #2623 - libc::CreateDirectoryW(p.as_ptr(), ptr::mut_null()) + libc::CreateDirectoryW(p.as_ptr(), ptr::null_mut()) }) } @@ -346,7 +346,7 @@ pub fn readdir(p: &CString) -> IoResult> { let root = unsafe { CString::new(root.as_ptr(), false) }; let root = Path::new(root); - dirs.move_iter().filter(|path| { + dirs.into_iter().filter(|path| { path.as_vec() != b"." && path.as_vec() != b".." }).map(|path| root.join(path).to_c_str()).collect() } @@ -428,10 +428,10 @@ pub fn readlink(p: &CString) -> IoResult { libc::CreateFileW(p.as_ptr(), libc::GENERIC_READ, libc::FILE_SHARE_READ, - ptr::mut_null(), + ptr::null_mut(), libc::OPEN_EXISTING, libc::FILE_ATTRIBUTE_NORMAL, - ptr::mut_null()) + ptr::null_mut()) }; if handle == libc::INVALID_HANDLE_VALUE { return Err(super::last_error()) @@ -468,7 +468,7 @@ pub fn link(src: &CString, dst: &CString) -> IoResult<()> { let src = try!(to_utf16(src)); let dst = try!(to_utf16(dst)); super::mkerr_winbool(unsafe { - libc::CreateHardLinkW(dst.as_ptr(), src.as_ptr(), ptr::mut_null()) + libc::CreateHardLinkW(dst.as_ptr(), src.as_ptr(), ptr::null_mut()) }) } diff --git a/src/libnative/io/helper_thread.rs b/src/libnative/io/helper_thread.rs index 8e92aa56d3c8f..1f51f8eacd634 100644 --- a/src/libnative/io/helper_thread.rs +++ b/src/libnative/io/helper_thread.rs @@ -172,7 +172,7 @@ mod imp { pub fn new() -> (HANDLE, HANDLE) { unsafe { - let handle = CreateEventA(ptr::mut_null(), libc::FALSE, libc::FALSE, + let handle = CreateEventA(ptr::null_mut(), libc::FALSE, libc::FALSE, ptr::null()); (handle, handle) } diff --git a/src/libnative/io/mod.rs b/src/libnative/io/mod.rs index 7881e088388ca..86f72bf65ddd3 100644 --- a/src/libnative/io/mod.rs +++ b/src/libnative/io/mod.rs @@ -267,7 +267,7 @@ impl rtio::IoFactory for IoFactory { Vec>>)> { process::Process::spawn(cfg).map(|(p, io)| { (box p as Box, - io.move_iter().map(|p| p.map(|p| { + io.into_iter().map(|p| p.map(|p| { box p as Box })).collect()) }) diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index ba951cdef26b9..af7508ccbe9a2 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -543,7 +543,7 @@ impl TcpAcceptor { while !self.inner.closed.load(atomic::SeqCst) { match retry(|| unsafe { - libc::accept(self.fd(), ptr::mut_null(), ptr::mut_null()) + libc::accept(self.fd(), ptr::null_mut(), ptr::null_mut()) }) { -1 if util::wouldblock() => {} -1 => return Err(os::last_error()), @@ -608,7 +608,7 @@ impl TcpAcceptor { if wsaevents.lNetworkEvents & c::FD_ACCEPT == 0 { continue } match unsafe { - libc::accept(self.fd(), ptr::mut_null(), ptr::mut_null()) + libc::accept(self.fd(), ptr::null_mut(), ptr::null_mut()) } { -1 if util::wouldblock() => {} -1 => return Err(os::last_error()), diff --git a/src/libnative/io/pipe_unix.rs b/src/libnative/io/pipe_unix.rs index a3564dfe2cc9a..c222907fa5b88 100644 --- a/src/libnative/io/pipe_unix.rs +++ b/src/libnative/io/pipe_unix.rs @@ -50,7 +50,7 @@ fn addr_to_sockaddr_un(addr: &CString, }) } s.sun_family = libc::AF_UNIX as libc::sa_family_t; - for (slot, value) in s.sun_path.mut_iter().zip(addr.iter()) { + for (slot, value) in s.sun_path.iter_mut().zip(addr.iter()) { *slot = value; } diff --git a/src/libnative/io/pipe_windows.rs b/src/libnative/io/pipe_windows.rs index 1f1880d712d8c..2de9cd9a41c4b 100644 --- a/src/libnative/io/pipe_windows.rs +++ b/src/libnative/io/pipe_windows.rs @@ -104,7 +104,7 @@ struct Event(libc::HANDLE); impl Event { fn new(manual_reset: bool, initial_state: bool) -> IoResult { let event = unsafe { - libc::CreateEventW(ptr::mut_null(), + libc::CreateEventW(ptr::null_mut(), manual_reset as libc::BOOL, initial_state as libc::BOOL, ptr::null()) @@ -164,7 +164,7 @@ unsafe fn pipe(name: *const u16, init: bool) -> libc::HANDLE { 65536, 65536, 0, - ptr::mut_null() + ptr::null_mut() ) } @@ -225,10 +225,10 @@ impl UnixStream { libc::CreateFileW(p, libc::GENERIC_READ | libc::GENERIC_WRITE, 0, - ptr::mut_null(), + ptr::null_mut(), libc::OPEN_EXISTING, libc::FILE_FLAG_OVERLAPPED, - ptr::mut_null()) + ptr::null_mut()) }; if result != libc::INVALID_HANDLE_VALUE { return Some(result) @@ -240,10 +240,10 @@ impl UnixStream { libc::CreateFileW(p, libc::GENERIC_READ | libc::FILE_WRITE_ATTRIBUTES, 0, - ptr::mut_null(), + ptr::null_mut(), libc::OPEN_EXISTING, libc::FILE_FLAG_OVERLAPPED, - ptr::mut_null()) + ptr::null_mut()) }; if result != libc::INVALID_HANDLE_VALUE { return Some(result) @@ -255,10 +255,10 @@ impl UnixStream { libc::CreateFileW(p, libc::GENERIC_WRITE | libc::FILE_READ_ATTRIBUTES, 0, - ptr::mut_null(), + ptr::null_mut(), libc::OPEN_EXISTING, libc::FILE_FLAG_OVERLAPPED, - ptr::mut_null()) + ptr::null_mut()) }; if result != libc::INVALID_HANDLE_VALUE { return Some(result) @@ -280,8 +280,8 @@ impl UnixStream { let ret = unsafe { libc::SetNamedPipeHandleState(inner.handle, &mut mode, - ptr::mut_null(), - ptr::mut_null()) + ptr::null_mut(), + ptr::null_mut()) }; return if ret == 0 { Err(super::last_error()) @@ -341,7 +341,7 @@ impl UnixStream { } fn cancel_io(&self) -> IoResult<()> { - match unsafe { c::CancelIoEx(self.handle(), ptr::mut_null()) } { + match unsafe { c::CancelIoEx(self.handle(), ptr::null_mut()) } { 0 if os::errno() == libc::ERROR_NOT_FOUND as uint => { Ok(()) } diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index e5165929ad388..cb392e1675feb 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -313,7 +313,7 @@ fn spawn_process_os(cfg: ProcessConfig, if b"PATH" != key.as_bytes_no_nul() { continue } // Split the value and test each path to see if the program exists. - for path in os::split_paths(v.as_bytes_no_nul()).move_iter() { + for path in os::split_paths(v.as_bytes_no_nul()).into_iter() { let path = path.join(cfg.program.as_bytes_no_nul()) .with_extension(os::consts::EXE_EXTENSION); if path.exists() { @@ -347,7 +347,7 @@ fn spawn_process_os(cfg: ProcessConfig, let size = mem::size_of::(); let mut sa = libc::SECURITY_ATTRIBUTES { nLength: size as libc::DWORD, - lpSecurityDescriptor: ptr::mut_null(), + lpSecurityDescriptor: ptr::null_mut(), bInheritHandle: 1, }; let filename: Vec = "NUL".utf16_units().collect(); @@ -359,7 +359,7 @@ fn spawn_process_os(cfg: ProcessConfig, &mut sa, libc::OPEN_EXISTING, 0, - ptr::mut_null()); + ptr::null_mut()); if *slot == INVALID_HANDLE_VALUE { return Err(super::last_error()) } @@ -399,8 +399,8 @@ fn spawn_process_os(cfg: ProcessConfig, cmd_str = cmd_str.append_one(0); let created = CreateProcessW(ptr::null(), cmd_str.as_mut_ptr(), - ptr::mut_null(), - ptr::mut_null(), + ptr::null_mut(), + ptr::null_mut(), TRUE, flags, envp, dirp, &mut si, &mut pi); @@ -437,9 +437,9 @@ fn spawn_process_os(cfg: ProcessConfig, fn zeroed_startupinfo() -> libc::types::os::arch::extra::STARTUPINFO { libc::types::os::arch::extra::STARTUPINFO { cb: 0, - lpReserved: ptr::mut_null(), - lpDesktop: ptr::mut_null(), - lpTitle: ptr::mut_null(), + lpReserved: ptr::null_mut(), + lpDesktop: ptr::null_mut(), + lpTitle: ptr::null_mut(), dwX: 0, dwY: 0, dwXSize: 0, @@ -450,7 +450,7 @@ fn zeroed_startupinfo() -> libc::types::os::arch::extra::STARTUPINFO { dwFlags: 0, wShowWindow: 0, cbReserved2: 0, - lpReserved2: ptr::mut_null(), + lpReserved2: ptr::null_mut(), hStdInput: libc::INVALID_HANDLE_VALUE, hStdOutput: libc::INVALID_HANDLE_VALUE, hStdError: libc::INVALID_HANDLE_VALUE, @@ -460,8 +460,8 @@ fn zeroed_startupinfo() -> libc::types::os::arch::extra::STARTUPINFO { #[cfg(windows)] fn zeroed_process_information() -> libc::types::os::arch::extra::PROCESS_INFORMATION { libc::types::os::arch::extra::PROCESS_INFORMATION { - hProcess: ptr::mut_null(), - hThread: ptr::mut_null(), + hProcess: ptr::null_mut(), + hThread: ptr::null_mut(), dwProcessId: 0, dwThreadId: 0 } @@ -596,7 +596,7 @@ fn spawn_process_os(cfg: ProcessConfig, Err(..) => { Ok(SpawnProcessResult { pid: pid, - handle: ptr::mut_null() + handle: ptr::null_mut() }) } Ok(..) => fail!("short read on the cloexec pipe"), @@ -806,7 +806,7 @@ fn with_envp(env: Option<&[(&CString, &CString)]>, cb: |*mut c_void| -> T) -> cb(blk.as_mut_ptr() as *mut c_void) } - _ => cb(ptr::mut_null()) + _ => cb(ptr::null_mut()) } } @@ -1050,14 +1050,14 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult { tv = util::ms_to_timeval(ms); (&mut tv as *mut _, idx) } - None => (ptr::mut_null(), -1), + None => (ptr::null_mut(), -1), }; // Wait for something to happen c::fd_set(&mut set, input); c::fd_set(&mut set, read_fd); - match unsafe { c::select(max, &mut set, ptr::mut_null(), - ptr::mut_null(), p) } { + match unsafe { c::select(max, &mut set, ptr::null_mut(), + ptr::null_mut(), p) } { // interrupted, retry -1 if os::errno() == libc::EINTR as int => continue, @@ -1129,7 +1129,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult { // Once this helper thread is done, we re-register the old sigchld // handler and close our intermediate file descriptors. unsafe { - assert_eq!(c::sigaction(c::SIGCHLD, &old, ptr::mut_null()), 0); + assert_eq!(c::sigaction(c::SIGCHLD, &old, ptr::null_mut()), 0); let _ = libc::close(read_fd); let _ = libc::close(WRITE_FD); WRITE_FD = -1; diff --git a/src/libnative/io/timer_unix.rs b/src/libnative/io/timer_unix.rs index 801434f81019f..0a5de325c0922 100644 --- a/src/libnative/io/timer_unix.rs +++ b/src/libnative/io/timer_unix.rs @@ -88,7 +88,7 @@ pub enum Req { pub fn now() -> u64 { unsafe { let mut now: libc::timeval = mem::zeroed(); - assert_eq!(c::gettimeofday(&mut now, ptr::mut_null()), 0); + assert_eq!(c::gettimeofday(&mut now, ptr::null_mut()), 0); return (now.tv_sec as u64) * 1000 + (now.tv_usec as u64) / 1000; } } @@ -133,7 +133,7 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { 'outer: loop { let timeout = if active.len() == 0 { // Empty array? no timeout (wait forever for the next request) - ptr::mut_null() + ptr::null_mut() } else { let now = now(); // If this request has already expired, then signal it and go @@ -154,8 +154,8 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { c::fd_set(&mut set, input); match unsafe { - c::select(input + 1, &mut set, ptr::mut_null(), - ptr::mut_null(), timeout) + c::select(input + 1, &mut set, ptr::null_mut(), + ptr::null_mut(), timeout) } { // timed out 0 => signal(&mut active, &mut dead), diff --git a/src/libnative/io/timer_windows.rs b/src/libnative/io/timer_windows.rs index 8d781f50d35d4..82d318111727f 100644 --- a/src/libnative/io/timer_windows.rs +++ b/src/libnative/io/timer_windows.rs @@ -107,7 +107,7 @@ impl Timer { unsafe { HELPER.boot(|| {}, helper) } let obj = unsafe { - imp::CreateWaitableTimerA(ptr::mut_null(), 0, ptr::null()) + imp::CreateWaitableTimerA(ptr::null_mut(), 0, ptr::null()) }; if obj.is_null() { Err(super::last_error()) @@ -141,8 +141,8 @@ impl rtio::RtioTimer for Timer { // 100ns intervals, so we multiply by 10^4. let due = -(msecs as i64 * 10000) as libc::LARGE_INTEGER; assert_eq!(unsafe { - imp::SetWaitableTimer(self.obj, &due, 0, ptr::mut_null(), - ptr::mut_null(), 0) + imp::SetWaitableTimer(self.obj, &due, 0, ptr::null_mut(), + ptr::null_mut(), 0) }, 1); let _ = unsafe { imp::WaitForSingleObject(self.obj, libc::INFINITE) }; @@ -154,8 +154,8 @@ impl rtio::RtioTimer for Timer { // see above for the calculation let due = -(msecs as i64 * 10000) as libc::LARGE_INTEGER; assert_eq!(unsafe { - imp::SetWaitableTimer(self.obj, &due, 0, ptr::mut_null(), - ptr::mut_null(), 0) + imp::SetWaitableTimer(self.obj, &due, 0, ptr::null_mut(), + ptr::null_mut(), 0) }, 1); unsafe { HELPER.send(NewTimer(self.obj, cb, true)) } @@ -169,7 +169,7 @@ impl rtio::RtioTimer for Timer { let due = -(msecs as i64 * 10000) as libc::LARGE_INTEGER; assert_eq!(unsafe { imp::SetWaitableTimer(self.obj, &due, msecs as libc::LONG, - ptr::mut_null(), ptr::mut_null(), 0) + ptr::null_mut(), ptr::null_mut(), 0) }, 1); unsafe { HELPER.send(NewTimer(self.obj, cb, false)) } diff --git a/src/libnative/io/tty_windows.rs b/src/libnative/io/tty_windows.rs index 7f344279cd5e4..7263036e1659e 100644 --- a/src/libnative/io/tty_windows.rs +++ b/src/libnative/io/tty_windows.rs @@ -98,7 +98,7 @@ impl RtioTTY for WindowsTTY { utf16.as_mut_ptr() as LPVOID, utf16.len() as u32, &mut num as LPDWORD, - ptr::mut_null()) } { + ptr::null_mut()) } { 0 => return Err(super::last_error()), _ => (), }; @@ -123,7 +123,7 @@ impl RtioTTY for WindowsTTY { utf16.as_ptr() as LPCVOID, utf16.len() as u32, &mut num as LPDWORD, - ptr::mut_null()) } { + ptr::null_mut()) } { 0 => Err(super::last_error()), _ => Ok(()), } diff --git a/src/libnative/io/util.rs b/src/libnative/io/util.rs index 078989b058180..5f69ec00cddd4 100644 --- a/src/libnative/io/util.rs +++ b/src/libnative/io/util.rs @@ -155,15 +155,15 @@ pub fn connect_timeout(fd: net::sock_t, // undefined what the value of the 'tv' is after select // returns EINTR). let mut tv = ms_to_timeval(timeout - (::io::timer::now() - start)); - c::select(fd + 1, ptr::mut_null(), set as *mut _, - ptr::mut_null(), &mut tv) + c::select(fd + 1, ptr::null_mut(), set as *mut _, + ptr::null_mut(), &mut tv) }) } #[cfg(windows)] fn await(_fd: net::sock_t, set: &mut c::fd_set, timeout: u64) -> libc::c_int { let mut tv = ms_to_timeval(timeout); - unsafe { c::select(1, ptr::mut_null(), set, ptr::mut_null(), &mut tv) } + unsafe { c::select(1, ptr::null_mut(), set, ptr::null_mut(), &mut tv) } } } @@ -180,15 +180,15 @@ pub fn await(fds: &[net::sock_t], deadline: Option, } let (read, write) = match status { - Readable => (&mut set as *mut _, ptr::mut_null()), - Writable => (ptr::mut_null(), &mut set as *mut _), + Readable => (&mut set as *mut _, ptr::null_mut()), + Writable => (ptr::null_mut(), &mut set as *mut _), }; let mut tv: libc::timeval = unsafe { mem::zeroed() }; match retry(|| { let now = ::io::timer::now(); let tvp = match deadline { - None => ptr::mut_null(), + None => ptr::null_mut(), Some(deadline) => { // If we're past the deadline, then pass a 0 timeout to // select() so we can poll the status @@ -198,7 +198,7 @@ pub fn await(fds: &[net::sock_t], deadline: Option, } }; let r = unsafe { - c::select(max as libc::c_int, read, write, ptr::mut_null(), tvp) + c::select(max as libc::c_int, read, write, ptr::null_mut(), tvp) }; r }) { diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index d15c65799f42e..89c8e90f2c38b 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -126,7 +126,7 @@ impl<'a, T: Clone> WeightedChoice<'a, T> { // we convert the list from individual weights to cumulative // weights so we can binary search. This *could* drop elements // with weight == 0 as an optimisation. - for item in items.mut_iter() { + for item in items.iter_mut() { running_total = match running_total.checked_add(&item.weight) { Some(n) => n, None => fail!("WeightedChoice::new called with a total weight \ diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 871328e9c1696..0a857da92bbe4 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -207,7 +207,7 @@ impl<'a> SeedableRng<&'a [u32]> for IsaacRng { // - 1], 0, 0, ...], to fill rng.rsl. let seed_iter = seed.iter().map(|&x| x).chain(Repeat::new(0u32)); - for (rsl_elem, seed_elem) in self.rsl.mut_iter().zip(seed_iter) { + for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) { *rsl_elem = seed_elem; } self.cnt = 0; @@ -442,7 +442,7 @@ impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng { // - 1], 0, 0, ...], to fill rng.rsl. let seed_iter = seed.iter().map(|&x| x).chain(Repeat::new(0u64)); - for (rsl_elem, seed_elem) in self.rsl.mut_iter().zip(seed_iter) { + for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) { *rsl_elem = seed_elem; } self.cnt = 0; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 52112380c600a..f8a775478f1f8 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -113,7 +113,7 @@ pub trait Rng { // optimisations are on. let mut count = 0i; let mut num = 0; - for byte in dest.mut_iter() { + for byte in dest.iter_mut() { if count == 0 { // we could micro-optimise here by generating a u32 if // we only need a few more bytes to fill the vector diff --git a/src/librbml/io.rs b/src/librbml/io.rs index 443bf4d34ffa1..51115990a3113 100644 --- a/src/librbml/io.rs +++ b/src/librbml/io.rs @@ -102,7 +102,7 @@ impl Writer for SeekableMemWriter { // Do the necessary writes if left.len() > 0 { - slice::bytes::copy_memory(self.buf.mut_slice_from(self.pos), left); + slice::bytes::copy_memory(self.buf.slice_from_mut(self.pos), left); } if right.len() > 0 { self.buf.push_all(right); diff --git a/src/libregex/compile.rs b/src/libregex/compile.rs index ea472abeee690..869dd25e3fab3 100644 --- a/src/libregex/compile.rs +++ b/src/libregex/compile.rs @@ -165,7 +165,7 @@ impl<'r> Compiler<'r> { self.push(Save(2 * cap + 1)); } Cat(xs) => { - for x in xs.move_iter() { + for x in xs.into_iter() { self.compile(x) } } diff --git a/src/libregex/parse.rs b/src/libregex/parse.rs index c3ce7bbd9f2ca..12555b7c44383 100644 --- a/src/libregex/parse.rs +++ b/src/libregex/parse.rs @@ -418,13 +418,13 @@ impl<'a> Parser<'a> { if ranges.len() > 0 { let flags = negated | (self.flags & FLAG_NOCASE); let mut ast = Class(combine_ranges(ranges), flags); - for alt in alts.move_iter() { + for alt in alts.into_iter() { ast = Alt(box alt, box ast) } self.push(ast); } else if alts.len() > 0 { let mut ast = alts.pop().unwrap(); - for alt in alts.move_iter() { + for alt in alts.into_iter() { ast = Alt(box alt, box ast) } self.push(ast); @@ -961,7 +961,7 @@ fn combine_ranges(unordered: Vec<(char, char)>) -> Vec<(char, char)> { // This is currently O(n^2), but I think with sufficient cleverness, // it can be reduced to O(n) **if necessary**. let mut ordered: Vec<(char, char)> = Vec::with_capacity(unordered.len()); - for (us, ue) in unordered.move_iter() { + for (us, ue) in unordered.into_iter() { let (mut us, mut ue) = (us, ue); assert!(us <= ue); let mut which: Option = None; diff --git a/src/libregex/test/bench.rs b/src/libregex/test/bench.rs index aa85a68b5b509..be8e12b09f020 100644 --- a/src/libregex/test/bench.rs +++ b/src/libregex/test/bench.rs @@ -157,7 +157,7 @@ fn gen_text(n: uint) -> String { let mut rng = task_rng(); let mut bytes = rng.gen_ascii_chars().map(|n| n as u8).take(n) .collect::>(); - for (i, b) in bytes.mut_iter().enumerate() { + for (i, b) in bytes.iter_mut().enumerate() { if i % 20 == 0 { *b = b'\n' } diff --git a/src/libregex/vm.rs b/src/libregex/vm.rs index 1adaf9c92a6ac..6db07923c4d57 100644 --- a/src/libregex/vm.rs +++ b/src/libregex/vm.rs @@ -204,7 +204,7 @@ impl<'r, 't> Nfa<'r, 't> { return StepMatch } Submatches => { - for (slot, val) in groups.mut_iter().zip(caps.iter()) { + for (slot, val) in groups.iter_mut().zip(caps.iter()) { *slot = *val; } return StepMatch @@ -470,7 +470,7 @@ impl Threads { *t.groups.get_mut(1) = groups[1]; } (false, Submatches) => { - for (slot, val) in t.groups.mut_iter().zip(groups.iter()) { + for (slot, val) in t.groups.iter_mut().zip(groups.iter()) { *slot = *val; } } diff --git a/src/libregex_macros/lib.rs b/src/libregex_macros/lib.rs index cd00e459a7998..128091840031d 100644 --- a/src/libregex_macros/lib.rs +++ b/src/libregex_macros/lib.rs @@ -283,7 +283,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str, t.groups[1] = groups[1]; } Submatches => { - for (slot, val) in t.groups.mut_iter().zip(groups.iter()) { + for (slot, val) in t.groups.iter_mut().zip(groups.iter()) { *slot = *val; } } @@ -449,7 +449,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str, return StepMatch } Submatches => { - for (slot, val) in groups.mut_iter().zip(caps.iter()) { + for (slot, val) in groups.iter_mut().zip(caps.iter()) { *slot = *val; } return StepMatch diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index cc4e47de007d5..de1eef1dce3be 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -378,7 +378,7 @@ pub fn mangle_internal_name_by_type_and_seq(ccx: &CrateContext, } pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> String { - mangle(path.chain(Some(gensym_name(flav)).move_iter()), None) + mangle(path.chain(Some(gensym_name(flav)).into_iter()), None) } pub fn get_cc_prog(sess: &Session) -> String { @@ -780,7 +780,7 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) { ab.add_rlib(&p, name.as_slice(), sess.lto()).unwrap(); let native_libs = csearch::get_native_libraries(&sess.cstore, cnum); - all_native_libs.extend(native_libs.move_iter()); + all_native_libs.extend(native_libs.into_iter()); } ab.update_symbols(); @@ -1381,7 +1381,7 @@ fn add_upstream_native_libraries(cmd: &mut Command, sess: &Session) { // we're just getting an ordering of crate numbers, we're not worried about // the paths. let crates = sess.cstore.get_used_crates(cstore::RequireStatic); - for (cnum, _) in crates.move_iter() { + for (cnum, _) in crates.into_iter() { let libs = csearch::get_native_libraries(&sess.cstore, cnum); for &(kind, ref lib) in libs.iter() { match kind { diff --git a/src/librustc/back/lto.rs b/src/librustc/back/lto.rs index d7f183faa0192..250557d0af1ac 100644 --- a/src/librustc/back/lto.rs +++ b/src/librustc/back/lto.rs @@ -46,7 +46,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef, // load the bitcode from the archive. Then merge it into the current LLVM // module that we've got. let crates = sess.cstore.get_used_crates(cstore::RequireStatic); - for (cnum, path) in crates.move_iter() { + for (cnum, path) in crates.into_iter() { let name = sess.cstore.get_crate_data(cnum).name.clone(); let path = match path { Some(p) => p, diff --git a/src/librustc/back/write.rs b/src/librustc/back/write.rs index 53bdf500a217b..cff5ac5375dcd 100644 --- a/src/librustc/back/write.rs +++ b/src/librustc/back/write.rs @@ -857,7 +857,7 @@ fn run_work_multithreaded(sess: &Session, } let mut failed = false; - for future in futures.move_iter() { + for future in futures.into_iter() { match future.unwrap() { Ok(()) => {}, Err(_) => { diff --git a/src/librustc/driver/config.rs b/src/librustc/driver/config.rs index f7b0a178734e1..309c7a44c5d9b 100644 --- a/src/librustc/driver/config.rs +++ b/src/librustc/driver/config.rs @@ -396,7 +396,7 @@ cgoptions!( pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions { let mut cg = basic_codegen_options(); - for option in matches.opt_strs("C").move_iter() { + for option in matches.opt_strs("C").into_iter() { let mut iter = option.as_slice().splitn(1, '='); let key = iter.next().unwrap(); let value = iter.next(); @@ -486,7 +486,7 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig { if sess.opts.test { append_configuration(&mut user_cfg, InternedString::new("test")) } - user_cfg.move_iter().collect::>().append(default_cfg.as_slice()) + user_cfg.into_iter().collect::>().append(default_cfg.as_slice()) } pub fn get_os(triple: &str) -> Option { @@ -630,7 +630,7 @@ pub fn optgroups() -> Vec { // Convert strings provided as --cfg [cfgspec] into a crate_cfg fn parse_cfgspecs(cfgspecs: Vec ) -> ast::CrateConfig { - cfgspecs.move_iter().map(|s| { + cfgspecs.into_iter().map(|s| { parse::parse_meta_from_source_str("cfgspec".to_string(), s.to_string(), Vec::new(), @@ -652,7 +652,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { let mut describe_lints = false; for &level in [lint::Allow, lint::Warn, lint::Deny, lint::Forbid].iter() { - for lint_name in matches.opt_strs(level.as_str()).move_iter() { + for lint_name in matches.opt_strs(level.as_str()).into_iter() { if lint_name.as_slice() == "help" { describe_lints = true; } else { diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index b80d53922f8a5..2f252fc042a21 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -237,11 +237,11 @@ pub fn phase_2_configure_and_expand(sess: &Session, { let mut ls = sess.lint_store.borrow_mut(); - for pass in lint_passes.move_iter() { + for pass in lint_passes.into_iter() { ls.register_pass(Some(sess), true, pass); } - for (name, to) in lint_groups.move_iter() { + for (name, to) in lint_groups.into_iter() { ls.register_group(Some(sess), true, name, to); } } @@ -701,7 +701,7 @@ pub fn collect_crate_types(session: &Session, // will be found in crate attributes. let mut base = session.opts.crate_types.clone(); if base.len() == 0 { - base.extend(attr_types.move_iter()); + base.extend(attr_types.into_iter()); if base.len() == 0 { base.push(link::default_output_for_target(session)); } @@ -709,7 +709,7 @@ pub fn collect_crate_types(session: &Session, base.dedup(); } - base.move_iter().filter(|crate_type| { + base.into_iter().filter(|crate_type| { let res = !link::invalid_output_for_target(session, *crate_type); if !res { diff --git a/src/librustc/driver/mod.rs b/src/librustc/driver/mod.rs index 5e00b9e9e0e05..d9ccfd260101b 100644 --- a/src/librustc/driver/mod.rs +++ b/src/librustc/driver/mod.rs @@ -170,7 +170,7 @@ Available lint options: "); fn sort_lints(lints: Vec<(&'static Lint, bool)>) -> Vec<&'static Lint> { - let mut lints: Vec<_> = lints.move_iter().map(|(x, _)| x).collect(); + let mut lints: Vec<_> = lints.into_iter().map(|(x, _)| x).collect(); lints.sort_by(|x: &&Lint, y: &&Lint| { match x.default_level.cmp(&y.default_level) { // The sort doesn't case-fold but it's doubtful we care. @@ -183,7 +183,7 @@ Available lint options: fn sort_lint_groups(lints: Vec<(&'static str, Vec, bool)>) -> Vec<(&'static str, Vec)> { - let mut lints: Vec<_> = lints.move_iter().map(|(x, y, _)| (x, y)).collect(); + let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect(); lints.sort_by(|&(x, _): &(&'static str, Vec), &(y, _): &(&'static str, Vec)| { x.cmp(&y) @@ -211,7 +211,7 @@ Available lint options: println!(" {} {:7.7s} {}", padded("----"), "-------", "-------"); let print_lints = |lints: Vec<&Lint>| { - for lint in lints.move_iter() { + for lint in lints.into_iter() { let name = lint.name_lower().replace("_", "-"); println!(" {} {:7.7s} {}", padded(name.as_slice()), lint.default_level.as_str(), lint.desc); @@ -235,10 +235,10 @@ Available lint options: println!(" {} {}", padded("----"), "---------"); let print_lint_groups = |lints: Vec<(&'static str, Vec)>| { - for (name, to) in lints.move_iter() { + for (name, to) in lints.into_iter() { let name = name.chars().map(|x| x.to_lowercase()) .collect::().replace("_", "-"); - let desc = to.move_iter().map(|x| x.as_str()).collect::>().connect(", "); + let desc = to.into_iter().map(|x| x.as_str()).collect::>().connect(", "); println!(" {} {}", padded(name.as_slice()), desc); } @@ -401,7 +401,7 @@ fn parse_crate_attrs(sess: &Session, input: &Input) -> &sess.parse_sess) } }; - result.move_iter().collect() + result.into_iter().collect() } pub fn early_error(msg: &str) -> ! { diff --git a/src/librustc/driver/pretty.rs b/src/librustc/driver/pretty.rs index 7c27f23d4857a..9b6d6d4620d36 100644 --- a/src/librustc/driver/pretty.rs +++ b/src/librustc/driver/pretty.rs @@ -342,7 +342,7 @@ impl UserIdentifiedItem { -> NodesMatchingUII<'a, 'ast> { match *self { ItemViaNode(node_id) => - NodesMatchingDirect(Some(node_id).move_iter()), + NodesMatchingDirect(Some(node_id).into_iter()), ItemViaPath(ref parts) => NodesMatchingSuffix(map.nodes_matching_suffix(parts.as_slice())), } diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index f028f5c97b7ef..2e05cb054e886 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -67,16 +67,16 @@ fn filter_view_item(cx: &mut Context, view_item: ast::ViewItem) -> Option ast::Mod { ast::Mod { inner: inner, - view_items: view_items.move_iter().filter_map(|a| { + view_items: view_items.into_iter().filter_map(|a| { filter_view_item(cx, a).map(|x| cx.fold_view_item(x)) }).collect(), - items: items.move_iter().filter_map(|a| { + items: items.into_iter().filter_map(|a| { if item_in_cfg(cx, &*a) { Some(cx.fold_item(a)) } else { None } - }).flat_map(|x| x.move_iter()).collect() + }).flat_map(|x| x.into_iter()).collect() } } @@ -93,10 +93,10 @@ fn fold_foreign_mod(cx: &mut Context, ast::ForeignMod {abi, view_items, items}: -> ast::ForeignMod { ast::ForeignMod { abi: abi, - view_items: view_items.move_iter().filter_map(|a| { + view_items: view_items.into_iter().filter_map(|a| { filter_view_item(cx, a).map(|x| cx.fold_view_item(x)) }).collect(), - items: items.move_iter() + items: items.into_iter() .filter_map(|a| filter_foreign_item(cx, a)) .collect() } @@ -105,13 +105,13 @@ fn fold_foreign_mod(cx: &mut Context, ast::ForeignMod {abi, view_items, items}: fn fold_item_underscore(cx: &mut Context, item: ast::Item_) -> ast::Item_ { let item = match item { ast::ItemImpl(a, b, c, impl_items) => { - let impl_items = impl_items.move_iter() + let impl_items = impl_items.into_iter() .filter(|ii| impl_item_in_cfg(cx, ii)) .collect(); ast::ItemImpl(a, b, c, impl_items) } ast::ItemTrait(a, b, c, methods) => { - let methods = methods.move_iter() + let methods = methods.into_iter() .filter(|m| trait_method_in_cfg(cx, m)) .collect(); ast::ItemTrait(a, b, c, methods) @@ -120,7 +120,7 @@ fn fold_item_underscore(cx: &mut Context, item: ast::Item_) -> ast::Item_ { ast::ItemStruct(fold_struct(cx, def), generics) } ast::ItemEnum(def, generics) => { - let mut variants = def.variants.move_iter().filter_map(|v| { + let mut variants = def.variants.into_iter().filter_map(|v| { if !(cx.in_cfg)(v.node.attrs.as_slice()) { None } else { @@ -158,7 +158,7 @@ fn fold_item_underscore(cx: &mut Context, item: ast::Item_) -> ast::Item_ { fn fold_struct(cx: &mut Context, def: P) -> P { def.map(|ast::StructDef {fields, ctor_id, super_struct, is_virtual}| { ast::StructDef { - fields: fields.move_iter().filter(|m| { + fields: fields.into_iter().filter(|m| { (cx.in_cfg)(m.node.attrs.as_slice()) }).collect(), ctor_id: ctor_id, @@ -185,11 +185,11 @@ fn retain_stmt(cx: &mut Context, stmt: &ast::Stmt) -> bool { fn fold_block(cx: &mut Context, b: P) -> P { b.map(|ast::Block {id, view_items, stmts, expr, rules, span}| { let resulting_stmts: Vec> = - stmts.move_iter().filter(|a| retain_stmt(cx, &**a)).collect(); - let resulting_stmts = resulting_stmts.move_iter() - .flat_map(|stmt| cx.fold_stmt(stmt).move_iter()) + stmts.into_iter().filter(|a| retain_stmt(cx, &**a)).collect(); + let resulting_stmts = resulting_stmts.into_iter() + .flat_map(|stmt| cx.fold_stmt(stmt).into_iter()) .collect(); - let filtered_view_items = view_items.move_iter().filter_map(|a| { + let filtered_view_items = view_items.into_iter().filter_map(|a| { filter_view_item(cx, a).map(|x| cx.fold_view_item(x)) }).collect(); ast::Block { @@ -209,7 +209,7 @@ fn fold_expr(cx: &mut Context, expr: P) -> P { id: id, node: match node { ast::ExprMatch(m, arms) => { - ast::ExprMatch(m, arms.move_iter() + ast::ExprMatch(m, arms.into_iter() .filter(|a| (cx.in_cfg)(a.attrs.as_slice())) .collect()) } diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index a8c9c50009588..737fe748340e6 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -160,7 +160,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { ast::Item { id: id, ident: ident, - attrs: attrs.move_iter().filter_map(|attr| { + attrs: attrs.into_iter().filter_map(|attr| { if !attr.check_name("main") { Some(attr) } else { @@ -195,11 +195,11 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec, let mut view_items = Vec::new(); let super_ = token::str_to_ident("super"); - view_items.extend(tests.move_iter().map(|r| { + view_items.extend(tests.into_iter().map(|r| { cx.ext_cx.view_use_simple(DUMMY_SP, ast::Public, cx.ext_cx.path(DUMMY_SP, vec![super_, r])) })); - view_items.extend(tested_submods.move_iter().map(|(r, sym)| { + view_items.extend(tested_submods.into_iter().map(|(r, sym)| { let path = cx.ext_cx.path(DUMMY_SP, vec![super_, r, sym]); cx.ext_cx.view_use_simple_(DUMMY_SP, ast::Public, r, path) })); @@ -444,7 +444,7 @@ fn path_node(ids: Vec ) -> ast::Path { ast::Path { span: DUMMY_SP, global: false, - segments: ids.move_iter().map(|identifier| ast::PathSegment { + segments: ids.into_iter().map(|identifier| ast::PathSegment { identifier: identifier, lifetimes: Vec::new(), types: OwnedSlice::empty(), @@ -552,7 +552,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P { ); } }; - visible_path.extend(path.move_iter()); + visible_path.extend(path.into_iter()); let fn_expr = ecx.expr_path(ecx.path_global(span, visible_path)); diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 4dd944415127e..c75b57dcafae0 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -259,7 +259,7 @@ macro_rules! run_lints ( ($cx:expr, $f:ident, $($args:expr),*) => ({ // Move the vector of passes out of `$cx` so that we can // iterate over it mutably while passing `$cx` to the methods. let mut passes = $cx.lints.passes.take().unwrap(); - for obj in passes.mut_iter() { + for obj in passes.iter_mut() { obj.$f($cx, $($args),*); } $cx.lints.passes = Some(passes); @@ -340,7 +340,7 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint, _ => sess.bug("impossible level in raw_emit_lint"), } - for span in note.move_iter() { + for span in note.into_iter() { sess.span_note(span, "lint level defined here"); } } @@ -411,7 +411,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> { // specified closure let mut pushed = 0u; - for result in gather_attrs(attrs).move_iter() { + for result in gather_attrs(attrs).into_iter() { let v = match result { Err(span) => { self.tcx.sess.span_err(span, "malformed lint attribute"); @@ -438,7 +438,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> { } }; - for (lint_id, level, span) in v.move_iter() { + for (lint_id, level, span) in v.into_iter() { let now = self.lints.get_level_source(lint_id).val0(); if now == Forbid && level != Forbid { let lint_name = lint_id.as_str(); @@ -667,7 +667,7 @@ impl<'a, 'tcx> IdVisitingOperation for Context<'a, 'tcx> { match self.tcx.sess.lints.borrow_mut().pop(&id) { None => {} Some(lints) => { - for (lint_id, span, msg) in lints.move_iter() { + for (lint_id, span, msg) in lints.into_iter() { self.span_lint(lint_id.lint, span, msg.as_slice()) } } diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index b82c9c93376e2..342a42fbb2611 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -85,11 +85,11 @@ fn warn_if_multiple_versions(diag: &SpanHandler, cstore: &CStore) { map.find_or_insert_with(data.name(), |_| Vec::new()).push(cnum); }); - for (name, dupes) in map.move_iter() { + for (name, dupes) in map.into_iter() { if dupes.len() == 1 { continue } diag.handler().warn( format!("using multiple versions of crate `{}`", name).as_slice()); - for dupe in dupes.move_iter() { + for dupe in dupes.into_iter() { let data = cstore.get_crate_data(dupe); diag.span_note(data.span, "used here"); loader::note_crate_name(diag, data.name().as_slice()); diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index bcf9a4f678d0a..c7af7b249398a 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1026,7 +1026,7 @@ fn get_meta_items(md: rbml::Doc) -> Vec> { let nd = reader::get_doc(meta_item_doc, tag_meta_item_name); let n = token::intern_and_get_ident(nd.as_str_slice()); let subitems = get_meta_items(meta_item_doc); - items.push(attr::mk_list_item(n, subitems.move_iter().collect())); + items.push(attr::mk_list_item(n, subitems.into_iter().collect())); true }); return items; @@ -1044,7 +1044,7 @@ fn get_attributes(md: rbml::Doc) -> Vec { // Currently it's only possible to have a single meta item on // an attribute assert_eq!(meta_items.len(), 1u); - let meta_item = meta_items.move_iter().nth(0).unwrap(); + let meta_item = meta_items.into_iter().nth(0).unwrap(); attrs.push( codemap::Spanned { node: ast::Attribute_ { diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 3ab50b0efd17c..c4f7c2db6a25f 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -873,7 +873,7 @@ fn encode_info_for_method(ecx: &EncodeContext, encode_bounds_and_type(rbml_w, ecx, &pty); let elem = ast_map::PathName(m.ident.name); - encode_path(rbml_w, impl_path.chain(Some(elem).move_iter())); + encode_path(rbml_w, impl_path.chain(Some(elem).into_iter())); match ast_item_opt { Some(&ast::MethodImplItem(ref ast_method)) => { encode_attributes(rbml_w, ast_method.attrs.as_slice()); @@ -1295,7 +1295,7 @@ fn encode_info_for_item(ecx: &EncodeContext, let elem = ast_map::PathName(method_ty.ident.name); encode_path(rbml_w, - path.clone().chain(Some(elem).move_iter())); + path.clone().chain(Some(elem).into_iter())); match method_ty.explicit_self { ty::StaticExplicitSelfCategory => { @@ -1497,7 +1497,7 @@ fn encode_info_for_items(ecx: &EncodeContext, fn encode_index(rbml_w: &mut Encoder, index: Vec>, write_fn: |&mut SeekableMemWriter, &T|) { let mut buckets: Vec>> = Vec::from_fn(256, |_| Vec::new()); - for elt in index.move_iter() { + for elt in index.into_iter() { let h = hash::hash(&elt.val) as uint; buckets.get_mut(h % 256).push(elt); } @@ -1913,7 +1913,7 @@ pub static metadata_encoding_version : &'static [u8] = &[b'r', b'u', b's', b't', pub fn encode_metadata(parms: EncodeParams, krate: &Crate) -> Vec { let mut wr = SeekableMemWriter::new(); encode_metadata_inner(&mut wr, parms, krate); - wr.unwrap().move_iter().collect() + wr.unwrap().into_iter().collect() } fn encode_metadata_inner(wr: &mut SeekableMemWriter, parms: EncodeParams, krate: &Crate) { diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index fc20a86af7064..f63705bfb9901 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -449,7 +449,7 @@ impl<'a> Context<'a> { // libraries corresponds to the crate id and hash criteria that this // search is being performed for. let mut libraries = Vec::new(); - for (_hash, (rlibs, dylibs)) in candidates.move_iter() { + for (_hash, (rlibs, dylibs)) in candidates.into_iter() { let mut metadata = None; let rlib = self.extract_one(rlibs, "rlib", &mut metadata); let dylib = self.extract_one(dylibs, "dylib", &mut metadata); @@ -470,7 +470,7 @@ impl<'a> Context<'a> { // libraries or not. match libraries.len() { 0 => None, - 1 => Some(libraries.move_iter().next().unwrap()), + 1 => Some(libraries.into_iter().next().unwrap()), _ => { self.sess.span_err(self.span, format!("multiple matching crates for `{}`", @@ -521,11 +521,11 @@ impl<'a> Context<'a> { if m.len() == 0 { return None } else if m.len() == 1 { - return Some(m.move_iter().next().unwrap()) + return Some(m.into_iter().next().unwrap()) } } - for lib in m.move_iter() { + for lib in m.into_iter() { info!("{} reading metadata from: {}", flavor, lib.display()); let metadata = match get_metadata_section(self.os, &lib) { Ok(blob) => { diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 21d0292d2fe3a..272b7111fb88f 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -330,7 +330,7 @@ struct NestedItemsDropper; impl Folder for NestedItemsDropper { fn fold_block(&mut self, blk: P) -> P { blk.and_then(|ast::Block {id, stmts, expr, rules, span, ..}| { - let stmts_sans_items = stmts.move_iter().filter_map(|stmt| { + let stmts_sans_items = stmts.into_iter().filter_map(|stmt| { let use_stmt = match stmt.node { ast::StmtExpr(_, _) | ast::StmtSemi(_, _) => true, ast::StmtDecl(ref decl, _) => { @@ -810,7 +810,7 @@ impl<'a> vtable_decoder_helpers for reader::Decoder<'a> { tcx: &ty::ctxt, cdata: &cstore::crate_metadata) -> typeck::vtable_param_res { self.read_to_vec(|this| Ok(this.read_vtable_origin(tcx, cdata))) - .unwrap().move_iter().collect() + .unwrap().into_iter().collect() } fn read_vtable_origin(&mut self, @@ -1466,7 +1466,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { cdata: &cstore::crate_metadata) -> Vec { self.read_to_vec(|this| Ok(this.read_ty_nodcx(tcx, cdata)) ) .unwrap() - .move_iter() + .into_iter() .collect() } @@ -1585,7 +1585,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { } fn read_tys(&mut self, dcx: &DecodeContext) -> Vec { - self.read_to_vec(|this| Ok(this.read_ty(dcx))).unwrap().move_iter().collect() + self.read_to_vec(|this| Ok(this.read_ty(dcx))).unwrap().into_iter().collect() } fn read_trait_ref(&mut self, dcx: &DecodeContext) -> Rc { @@ -1917,7 +1917,7 @@ fn decode_side_tables(dcx: &DecodeContext, c::tag_table_freevars => { let fv_info = val_dsr.read_to_vec(|val_dsr| { Ok(val_dsr.read_freevar_entry(dcx)) - }).unwrap().move_iter().collect(); + }).unwrap().into_iter().collect(); dcx.tcx.freevars.borrow_mut().insert(id, fv_info); } c::tag_table_upvar_borrow_map => { diff --git a/src/librustc/middle/borrowck/gather_loans/move_error.rs b/src/librustc/middle/borrowck/gather_loans/move_error.rs index 4f9e51a64f451..b826768c93728 100644 --- a/src/librustc/middle/borrowck/gather_loans/move_error.rs +++ b/src/librustc/middle/borrowck/gather_loans/move_error.rs @@ -95,7 +95,7 @@ fn group_errors_with_same_origin(errors: &Vec) } else { Vec::new() }; - for ge in grouped_errors.mut_iter() { + for ge in grouped_errors.iter_mut() { if move_from_id == ge.move_from.id && error.move_to.is_some() { debug!("appending move_to to list"); ge.move_to_places.push_all_move(move_to); diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index 05cc61a754749..f1c288ae7a9aa 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -421,7 +421,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { ast::ExprIndex(ref l, ref r) | ast::ExprBinary(_, ref l, ref r) if self.is_method_call(expr) => { - self.call(expr, pred, &**l, Some(&**r).move_iter()) + self.call(expr, pred, &**l, Some(&**r).into_iter()) } ast::ExprUnary(_, ref e) if self.is_method_call(expr) => { @@ -461,7 +461,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { ast::ExprParen(ref e) | ast::ExprField(ref e, _, _) | ast::ExprTupField(ref e, _, _) => { - self.straightline(expr, pred, Some(&**e).move_iter()) + self.straightline(expr, pred, Some(&**e).into_iter()) } ast::ExprInlineAsm(ref inline_asm) => { diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index eb308f903d3dd..d3321e555a40a 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -72,9 +72,9 @@ impl<'a> fmt::Show for Matrix<'a> { let total_width = column_widths.iter().map(|n| *n).sum() + column_count * 3 + 1; let br = String::from_char(total_width, '+'); try!(write!(f, "{}\n", br)); - for row in pretty_printed_matrix.move_iter() { + for row in pretty_printed_matrix.into_iter() { try!(write!(f, "+")); - for (column, pat_str) in row.move_iter().enumerate() { + for (column, pat_str) in row.into_iter().enumerate() { try!(write!(f, " ")); f.width = Some(*column_widths.get(column)); try!(f.pad(pat_str.as_slice())); @@ -369,7 +369,7 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> { fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor, pats: Vec<&Pat>, left_ty: ty::t) -> P { let pats_len = pats.len(); - let mut pats = pats.move_iter().map(|p| P((*p).clone())); + let mut pats = pats.into_iter().map(|p| P((*p).clone())); let pat = match ty::get(left_ty).sty { ty::ty_tup(_) => PatTup(pats.collect()), @@ -383,7 +383,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor, }; if is_structure { let fields = ty::lookup_struct_fields(cx.tcx, vid); - let field_pats: Vec = fields.move_iter() + let field_pats: Vec = fields.into_iter() .zip(pats) .filter(|&(_, ref pat)| pat.node != PatWild(PatWildSingle)) .map(|(field, pat)| FieldPat { @@ -450,10 +450,10 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor, fn missing_constructor(cx: &MatchCheckCtxt, &Matrix(ref rows): &Matrix, left_ty: ty::t, max_slice_length: uint) -> Option { let used_constructors: Vec = rows.iter() - .flat_map(|row| pat_constructors(cx, *row.get(0), left_ty, max_slice_length).move_iter()) + .flat_map(|row| pat_constructors(cx, *row.get(0), left_ty, max_slice_length).into_iter()) .collect(); all_constructors(cx, left_ty, max_slice_length) - .move_iter() + .into_iter() .find(|c| !used_constructors.contains(c)) } @@ -536,7 +536,7 @@ fn is_useful(cx: &MatchCheckCtxt, if constructors.is_empty() { match missing_constructor(cx, matrix, left_ty, max_slice_length) { None => { - all_constructors(cx, left_ty, max_slice_length).move_iter().map(|c| { + all_constructors(cx, left_ty, max_slice_length).into_iter().map(|c| { match is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness) { UsefulWithWitness(pats) => UsefulWithWitness({ let arity = constructor_arity(cx, &c, left_ty); @@ -547,7 +547,7 @@ fn is_useful(cx: &MatchCheckCtxt, }); vec![construct_witness(cx, &c, subpats, left_ty)] }; - result.extend(pats.move_iter().skip(arity)); + result.extend(pats.into_iter().skip(arity)); result }), result => result @@ -569,7 +569,7 @@ fn is_useful(cx: &MatchCheckCtxt, let wild_pats = Vec::from_elem(arity, &DUMMY_WILD_PAT); let enum_pat = construct_witness(cx, &constructor, wild_pats, left_ty); let mut new_pats = vec![enum_pat]; - new_pats.extend(pats.move_iter()); + new_pats.extend(pats.into_iter()); UsefulWithWitness(new_pats) }, result => result @@ -577,7 +577,7 @@ fn is_useful(cx: &MatchCheckCtxt, } } } else { - constructors.move_iter().map(|c| + constructors.into_iter().map(|c| is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness) ).find(|result| result != &NotUseful).unwrap_or(NotUseful) } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index d39b560c6d530..cc1789ec642e2 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -229,7 +229,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index); let (start, end) = self.compute_id_range(cfgidx); - let gens = self.gens.mut_slice(start, end); + let gens = self.gens.slice_mut(start, end); set_bit(gens, bit); } @@ -242,7 +242,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index); let (start, end) = self.compute_id_range(cfgidx); - let kills = self.kills.mut_slice(start, end); + let kills = self.kills.slice_mut(start, end); set_bit(kills, bit); } @@ -415,7 +415,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { } if changed { - let bits = self.kills.mut_slice(start, end); + let bits = self.kills.slice_mut(start, end); debug!("{:s} add_kills_from_flow_exits flow_exit={} bits={} [before]", self.analysis_name, flow_exit, mut_bits_to_string(bits)); bits.copy_from(orig_kills.as_slice()); @@ -498,7 +498,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> { fn reset(&mut self, bits: &mut [uint]) { let e = if self.dfcx.oper.initial_value() {uint::MAX} else {0}; - for b in bits.mut_iter() { + for b in bits.iter_mut() { *b = e; } } @@ -525,7 +525,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> { let (start, end) = self.dfcx.compute_id_range(cfgidx); let changed = { // (scoping mutable borrow of self.dfcx.on_entry) - let on_entry = self.dfcx.on_entry.mut_slice(start, end); + let on_entry = self.dfcx.on_entry.slice_mut(start, end); bitwise(on_entry, pred_bits, &self.dfcx.oper) }; if changed { @@ -566,7 +566,7 @@ fn bitwise(out_vec: &mut [uint], op: &Op) -> bool { assert_eq!(out_vec.len(), in_vec.len()); let mut changed = false; - for (out_elt, in_elt) in out_vec.mut_iter().zip(in_vec.iter()) { + for (out_elt, in_elt) in out_vec.iter_mut().zip(in_vec.iter()) { let old_val = *out_elt; let new_val = op.join(old_val, *in_elt); *out_elt = new_val; diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index f13c6bc3336fc..a9c0b877d55b7 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -302,7 +302,7 @@ fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool { } let dead_code = lint::builtin::DEAD_CODE.name_lower(); - for attr in lint::gather_attrs(attrs).move_iter() { + for attr in lint::gather_attrs(attrs).into_iter() { match attr { Ok((ref name, lint::Allow, _)) if name.get() == dead_code.as_slice() => return true, diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index 38e4426e4c878..8e2d4d0dc5a94 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -224,7 +224,7 @@ fn add_library(sess: &session::Session, fn attempt_static(sess: &session::Session) -> Option { let crates = sess.cstore.get_used_crates(cstore::RequireStatic); if crates.iter().all(|&(_, ref p)| p.is_some()) { - Some(crates.move_iter().map(|_| Some(cstore::RequireStatic)).collect()) + Some(crates.into_iter().map(|_| Some(cstore::RequireStatic)).collect()) } else { None } diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index ac1a62b185231..e3806f02ed4c8 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -121,7 +121,7 @@ pub fn def_to_path(tcx: &ty::ctxt, id: DefId) -> Path { identifier: Ident::new(elem.name()), lifetimes: vec!(), types: OwnedSlice::empty() - }).move_iter().collect(), + }).into_iter().collect(), span: DUMMY_SP, }) } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 1a2bda605daba..ded4883350ff2 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -6045,7 +6045,7 @@ impl<'a> Resolver<'a> { if idents.len() == 0 { return "???".to_string(); } - self.idents_to_string(idents.move_iter().rev() + self.idents_to_string(idents.into_iter().rev() .collect::>() .as_slice()) } diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 5559f222fe219..4b35024ecb05f 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -64,7 +64,7 @@ impl HomogeneousTuple3 for (T, T, T) { } fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { - self.as_mut_slice().mut_iter() + self.as_mut_slice().iter_mut() } fn get<'a>(&'a self, index: uint) -> Option<&'a T> { @@ -350,7 +350,7 @@ impl VecPerParamSpace { pub fn sort(t: Vec, space: |&T| -> ParamSpace) -> VecPerParamSpace { let mut result = VecPerParamSpace::empty(); - for t in t.move_iter() { + for t in t.into_iter() { result.push(space(&t), t); } result @@ -394,7 +394,7 @@ impl VecPerParamSpace { pub fn replace(&mut self, space: ParamSpace, elems: Vec) { // FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n). self.truncate(space, 0); - for t in elems.move_iter() { + for t in elems.into_iter() { self.push(space, t); } } @@ -420,7 +420,7 @@ impl VecPerParamSpace { pub fn get_mut_slice<'a>(&'a mut self, space: ParamSpace) -> &'a mut [T] { let (start, limit) = self.limits(space); - self.content.mut_slice(start, limit) + self.content.slice_mut(start, limit) } pub fn opt_get<'a>(&'a self, @@ -471,9 +471,9 @@ impl VecPerParamSpace { pub fn map_move(self, pred: |T| -> U) -> VecPerParamSpace { let (t, s, f) = self.split(); - VecPerParamSpace::new(t.move_iter().map(|p| pred(p)).collect(), - s.move_iter().map(|p| pred(p)).collect(), - f.move_iter().map(|p| pred(p)).collect()) + VecPerParamSpace::new(t.into_iter().map(|p| pred(p)).collect(), + s.into_iter().map(|p| pred(p)).collect(), + f.into_iter().map(|p| pred(p)).collect()) } pub fn map_rev(&self, pred: |&T| -> U) -> VecPerParamSpace { diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index 78d105c251edb..22392f3f1c0ac 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -142,7 +142,7 @@ impl FulfillmentContext { // Now go through all the successful ones, // registering any nested obligations for the future. - for selection in selections.move_iter() { + for selection in selections.into_iter() { selection.map_move_nested( |o| self.register_obligation(tcx, o)); } @@ -247,4 +247,3 @@ impl FulfillmentContext { } } } - diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 755ff991fb60a..3b670dc04fd42 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1735,7 +1735,7 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, .iter() .chain(slice.iter()) .chain(after.iter()) - .zip(extracted.vals.move_iter()) + .zip(extracted.vals.into_iter()) .fold(bcx, |bcx, (inner, elem)| bind_irrefutable_pat(bcx, &**inner, elem, binding_mode, cleanup_scope) ); diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index c474aab9b2647..a5e6d606d7bc1 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -80,7 +80,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) let mut constraints = String::from_str(constraints.iter() .map(|s| s.get().to_string()) - .chain(ext_constraints.move_iter()) + .chain(ext_constraints.into_iter()) .collect::>() .connect(",") .as_slice()); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 0716d8dbf27f4..a0cb8810289fa 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1631,7 +1631,7 @@ fn copy_args_to_allocas<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>, let arg_scope_id = cleanup::CustomScope(arg_scope); - for (i, arg_datum) in arg_datums.move_iter().enumerate() { + for (i, arg_datum) in arg_datums.into_iter().enumerate() { // For certain mode/type combinations, the raw llarg values are passed // by value. However, within the fn body itself, we want to always // have all locals and arguments be by-ref so that we can cancel the @@ -1662,7 +1662,7 @@ fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>( assert_eq!(arg_datums.len(), 1); - let arg_datum = arg_datums.move_iter().next().unwrap(); + let arg_datum = arg_datums.into_iter().next().unwrap(); // Untuple the rest of the arguments. let tuple_datum = @@ -2062,7 +2062,7 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext, if !type_is_zero_size(fcx.ccx, result_ty) { let dest = fcx.get_ret_slot(bcx, result_ty, "eret_slot"); let repr = adt::represent_type(ccx, result_ty); - for (i, arg_datum) in arg_datums.move_iter().enumerate() { + for (i, arg_datum) in arg_datums.into_iter().enumerate() { let lldestptr = adt::trans_field_ptr(bcx, &*repr, dest, @@ -3133,7 +3133,7 @@ pub fn trans_crate<'tcx>(analysis: CrateAnalysis<'tcx>) // the final product, so LTO needs to preserve them. shared_ccx.sess().cstore.iter_crate_data(|cnum, _| { let syms = csearch::get_reachable_extern_fns(&shared_ccx.sess().cstore, cnum); - reachable.extend(syms.move_iter().map(|did| { + reachable.extend(syms.into_iter().map(|did| { csearch::get_symbol(&shared_ccx.sess().cstore, did) })); }); diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index ca7adb97f3d54..e95f640b44869 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -547,7 +547,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // we care about. if ixs.len() < 16 { let mut small_vec = [ C_i32(self.ccx, 0), ..16 ]; - for (small_vec_e, &ix) in small_vec.mut_iter().zip(ixs.iter()) { + for (small_vec_e, &ix) in small_vec.iter_mut().zip(ixs.iter()) { *small_vec_e = C_i32(self.ccx, ix as i32); } self.inbounds_gep(base, small_vec.slice(0, ixs.len())) diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 0d4cb637ae0cd..2fd58303de309 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -145,7 +145,7 @@ fn classify_ty(ty: Type) -> Vec { } fn all_mem(cls: &mut [RegClass]) { - for elt in cls.mut_iter() { + for elt in cls.iter_mut() { *elt = Memory; } } diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index 4d54308031e92..cdc0bd76225aa 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -382,7 +382,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { debug!("schedule_clean_in_ast_scope(cleanup_scope={:?})", cleanup_scope); - for scope in self.scopes.borrow_mut().mut_iter().rev() { + for scope in self.scopes.borrow_mut().iter_mut().rev() { if scope.kind.is_ast_with_id(cleanup_scope) { scope.cleanups.push(cleanup); scope.clear_cached_exits(); @@ -712,7 +712,7 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx // Check if a landing pad block exists; if not, create one. { let mut scopes = self.scopes.borrow_mut(); - let last_scope = scopes.mut_last().unwrap(); + let last_scope = scopes.last_mut().unwrap(); match last_scope.cached_landing_pad { Some(llbb) => { return llbb; } None => { diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 2fac6e80ba085..6ab344ff69e93 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -197,7 +197,7 @@ pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Copy expr values into boxed bindings. let mut bcx = bcx; - for (i, bv) in bound_values.move_iter().enumerate() { + for (i, bv) in bound_values.into_iter().enumerate() { debug!("Copy {} into closure", bv.to_string(ccx)); if ccx.sess().asm_comments() { diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index 093849b47ad98..962f97ab74c6f 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -422,8 +422,8 @@ impl LocalCrateContext { adt_reprs: RefCell::new(HashMap::new()), type_hashcodes: RefCell::new(HashMap::new()), all_llvm_symbols: RefCell::new(HashSet::new()), - int_type: Type::from_ref(ptr::mut_null()), - opaque_vec_type: Type::from_ref(ptr::mut_null()), + int_type: Type::from_ref(ptr::null_mut()), + opaque_vec_type: Type::from_ref(ptr::null_mut()), builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)), unboxed_closure_vals: RefCell::new(DefIdMap::new()), dbg_cx: dbg_cx, diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 21ba2189414c2..a600baba5540c 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -822,7 +822,7 @@ pub fn create_global_var_metadata(cx: &CrateContext, type_metadata, is_local_to_unit, global, - ptr::mut_null()); + ptr::null_mut()); } }) }); @@ -1014,7 +1014,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) { } }; - if unsafe { llvm::LLVMIsAAllocaInst(llarg.val) } == ptr::mut_null() { + if unsafe { llvm::LLVMIsAAllocaInst(llarg.val) } == ptr::null_mut() { cx.sess().span_bug(span, "debuginfo::create_argument_metadata() - \ Referenced variable location is not an alloca!"); } @@ -1273,7 +1273,7 @@ pub fn create_function_debug_context(cx: &CrateContext, cx.sess().opts.optimize != config::No, llfn, template_parameters, - ptr::mut_null()) + ptr::null_mut()) } }) }); @@ -1308,7 +1308,7 @@ pub fn create_function_debug_context(cx: &CrateContext, // Return type -- llvm::DIBuilder wants this at index 0 match fn_decl.output.node { ast::TyNil => { - signature.push(ptr::mut_null()); + signature.push(ptr::null_mut()); } _ => { assert_type_for_node_id(cx, fn_ast_id, error_span); @@ -1382,7 +1382,7 @@ pub fn create_function_debug_context(cx: &CrateContext, file_metadata, name, actual_self_type_metadata, - ptr::mut_null(), + ptr::null_mut(), 0, 0) } @@ -1417,7 +1417,7 @@ pub fn create_function_debug_context(cx: &CrateContext, file_metadata, name, actual_type_metadata, - ptr::mut_null(), + ptr::null_mut(), 0, 0) } @@ -2410,7 +2410,7 @@ fn prepare_enum_metadata(cx: &CrateContext, bytes_to_bits(enum_type_size), bytes_to_bits(enum_type_align), 0, // Flags - ptr::mut_null(), + ptr::null_mut(), 0, // RuntimeLang unique_type_id_str) } @@ -2581,10 +2581,10 @@ fn create_struct_stub(cx: &CrateContext, bytes_to_bits(struct_size), bytes_to_bits(struct_align), 0, - ptr::mut_null(), + ptr::null_mut(), empty_array, 0, - ptr::mut_null(), + ptr::null_mut(), unique_type_id) }) }) @@ -2798,7 +2798,7 @@ fn subroutine_type_metadata(cx: &CrateContext, // return type signature_metadata.push(match ty::get(signature.output).sty { - ty::ty_nil => ptr::mut_null(), + ty::ty_nil => ptr::null_mut(), _ => type_metadata(cx, signature.output, span) }); @@ -3074,7 +3074,7 @@ fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) { let col = UNKNOWN_COLUMN_NUMBER; debug!("setting debug location to {} {}", line, col); let elements = [C_i32(cx, line as i32), C_i32(cx, col as i32), - scope, ptr::mut_null()]; + scope, ptr::null_mut()]; unsafe { metadata_node = llvm::LLVMMDNodeInContext(debug_context(cx).llcontext, elements.as_ptr(), @@ -3083,7 +3083,7 @@ fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) { } UnknownLocation => { debug!("clearing debug location "); - metadata_node = ptr::mut_null(); + metadata_node = ptr::null_mut(); } }; @@ -3953,7 +3953,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc> = None; @@ -3981,7 +3981,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc node.scope, - None => ptr::mut_null() + None => ptr::null_mut() }; let namespace_name = token::get_name(name); let scope = namespace_name.get().with_c_str(|namespace_name| { @@ -3991,7 +3991,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc { - emit_vtable_methods(bcx, id, substs).move_iter() + emit_vtable_methods(bcx, id, substs).into_iter() } traits::VtableUnboxedClosure(closure_def_id) => { let callee_substs = @@ -626,7 +626,7 @@ pub fn get_vtable(bcx: Block, } } - (vec!(llfn)).move_iter() + (vec!(llfn)).into_iter() } traits::VtableBuiltin | traits::VtableParam(..) => { @@ -662,7 +662,7 @@ pub fn make_vtable>(ccx: &CrateContext, let _icx = push_ctxt("meth::make_vtable"); let head = vec![drop_glue, size, align]; - let components: Vec<_> = head.move_iter().chain(ptrs).collect(); + let components: Vec<_> = head.into_iter().chain(ptrs).collect(); unsafe { let tbl = C_struct(ccx, components.as_slice(), false); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index d0b94cb3abb8b..bd472195b958c 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4488,7 +4488,7 @@ pub fn lookup_repr_hints(tcx: &ctxt, did: DefId) -> Vec { let mut acc = Vec::new(); ty::each_attr(tcx, did, |meta| { - acc.extend(attr::find_repr_attrs(tcx.sess.diagnostic(), meta).move_iter()); + acc.extend(attr::find_repr_attrs(tcx.sess.diagnostic(), meta).into_iter()); true }); diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index f2fe7fe628221..cb449f80ed4a4 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -197,7 +197,7 @@ fn ast_path_substs<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( } match anon_regions { - Ok(v) => v.move_iter().collect(), + Ok(v) => v.into_iter().collect(), Err(()) => Vec::from_fn(expected_num_region_params, |_| ty::ReStatic) // hokey } @@ -1012,7 +1012,7 @@ fn ty_of_method_or_bare_fn<'tcx, AC: AstConv<'tcx>>( }; let input_tys = input_tys.iter().map(|a| ty_of_arg(this, &rb, a, None)); let self_and_input_tys: Vec<_> = - self_ty.move_iter().chain(input_tys).collect(); + self_ty.into_iter().chain(input_tys).collect(); // Second, if there was exactly one lifetime (either a substitution or a // reference) in the arguments, then any anonymous regions in the output diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 46aba94a5f12a..17cfa040804e1 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -179,7 +179,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path, kind_name = "[error]"; arg_types = subpats.clone() .unwrap_or_default() - .move_iter() + .into_iter() .map(|_| ty::mk_err()) .collect(); } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 074074c13ae90..d3cae157d3b2c 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -509,7 +509,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { // find all the impls of that trait. Each of those are // candidates. let opt_applicable_traits = self.fcx.ccx.trait_map.find(&expr_id); - for applicable_traits in opt_applicable_traits.move_iter() { + for applicable_traits in opt_applicable_traits.into_iter() { for trait_did in applicable_traits.iter() { debug!("push_extension_candidates() found trait: {}", if trait_did.krate == ast::LOCAL_CRATE { @@ -1322,7 +1322,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { let args = fn_sig.inputs.slice_from(1).iter().map(|t| { t.subst(tcx, &all_substs) }); - Some(*fn_sig.inputs.get(0)).move_iter().chain(args).collect() + Some(*fn_sig.inputs.get(0)).into_iter().chain(args).collect() } _ => fn_sig.inputs.subst(tcx, &all_substs) }; diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 45ffddf3fe80e..37b77e872ca69 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -650,7 +650,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { ast::ExprAssignOp(_, ref lhs, ref rhs) => { if has_method_map { constrain_call(rcx, expr, Some(&**lhs), - Some(&**rhs).move_iter(), true); + Some(&**rhs).into_iter(), true); } adjust_borrow_kind_for_assignment_lhs(rcx, &**lhs); @@ -665,7 +665,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { // implicit "by ref" sort of passing style here. This // should be converted to an adjustment! constrain_call(rcx, expr, Some(&**lhs), - Some(&**rhs).move_iter(), true); + Some(&**rhs).into_iter(), true); visit::walk_expr(rcx, expr); } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 581bd8acbc97e..c7b4a78492bb7 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -560,7 +560,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) { convert_methods(ccx, ImplContainer(local_def(it.id)), - methods.move_iter(), + methods.into_iter(), selfty, &ty_generics, parent_visibility); @@ -1273,10 +1273,10 @@ fn conv_param_bounds(ccx: &CrateCtxt, unboxed_fn_ty_bounds } = astconv::partition_bounds(ccx.tcx, span, all_bounds.as_slice()); let unboxed_fn_ty_bounds = - unboxed_fn_ty_bounds.move_iter() + unboxed_fn_ty_bounds.into_iter() .map(|b| instantiate_unboxed_fn_ty(ccx, b, param_ty)); let trait_bounds: Vec> = - trait_bounds.move_iter() + trait_bounds.into_iter() .map(|b| instantiate_trait_ref(ccx, b, param_ty.to_ty(ccx.tcx))) .chain(unboxed_fn_ty_bounds) .collect(); diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 4f663df58824a..499740a78ef39 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -335,7 +335,7 @@ impl<'a, 'tcx> ErrorReporting for InferCtxt<'a, 'tcx> { same_frs: &FreeRegionsFromSameFn) { let scope_id = same_frs.scope_id; let (sub_fr, sup_fr) = (same_frs.sub_fr, same_frs.sup_fr); - for sr in same_regions.mut_iter() { + for sr in same_regions.iter_mut() { if sr.contains(&sup_fr.bound_region) && scope_id == sr.scope_id { sr.push(sub_fr.bound_region); @@ -1328,7 +1328,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { ast::TyFixedLengthVec(build_to(ty, to), e) } ast::TyTup(tys) => { - ast::TyTup(tys.move_iter().map(|ty| build_to(ty, to)).collect()) + ast::TyTup(tys.into_iter().map(|ty| build_to(ty, to)).collect()) } ast::TyParen(typ) => ast::TyParen(build_to(typ, to)), other => other diff --git a/src/librustc/plugin/registry.rs b/src/librustc/plugin/registry.rs index 2b2fc8c94d4ac..be31e81d29baf 100644 --- a/src/librustc/plugin/registry.rs +++ b/src/librustc/plugin/registry.rs @@ -84,6 +84,6 @@ impl Registry { /// Register a lint group. pub fn register_lint_group(&mut self, name: &'static str, to: Vec<&'static Lint>) { - self.lint_groups.insert(name, to.move_iter().map(|x| LintId::of(x)).collect()); + self.lint_groups.insert(name, to.into_iter().map(|x| LintId::of(x)).collect()); } } diff --git a/src/librustc_back/rpath.rs b/src/librustc_back/rpath.rs index 98fdd5a7fd7db..e0946366abc81 100644 --- a/src/librustc_back/rpath.rs +++ b/src/librustc_back/rpath.rs @@ -47,7 +47,7 @@ pub fn get_rpath_flags(config: RPathConfig) -> Vec { debug!("preparing the RPATH!"); let libs = config.used_crates.clone(); - let libs = libs.move_iter().filter_map(|(_, l)| { + let libs = libs.into_iter().filter_map(|(_, l)| { l.map(|p| p.clone()) }).collect::>(); diff --git a/src/librustc_back/sha2.rs b/src/librustc_back/sha2.rs index d24ff49c61558..8f3dd18c69c59 100644 --- a/src/librustc_back/sha2.rs +++ b/src/librustc_back/sha2.rs @@ -136,14 +136,14 @@ impl FixedBuffer for FixedBuffer64 { let buffer_remaining = size - self.buffer_idx; if input.len() >= buffer_remaining { copy_memory( - self.buffer.mut_slice(self.buffer_idx, size), + self.buffer.slice_mut(self.buffer_idx, size), input.slice_to(buffer_remaining)); self.buffer_idx = 0; func(self.buffer); i += buffer_remaining; } else { copy_memory( - self.buffer.mut_slice(self.buffer_idx, self.buffer_idx + input.len()), + self.buffer.slice_mut(self.buffer_idx, self.buffer_idx + input.len()), input); self.buffer_idx += input.len(); return; @@ -162,7 +162,7 @@ impl FixedBuffer for FixedBuffer64 { // be empty. let input_remaining = input.len() - i; copy_memory( - self.buffer.mut_slice(0, input_remaining), + self.buffer.slice_mut(0, input_remaining), input.slice_from(i)); self.buffer_idx += input_remaining; } @@ -173,13 +173,13 @@ impl FixedBuffer for FixedBuffer64 { fn zero_until(&mut self, idx: uint) { assert!(idx >= self.buffer_idx); - self.buffer.mut_slice(self.buffer_idx, idx).set_memory(0); + self.buffer.slice_mut(self.buffer_idx, idx).set_memory(0); self.buffer_idx = idx; } fn next<'s>(&'s mut self, len: uint) -> &'s mut [u8] { self.buffer_idx += len; - return self.buffer.mut_slice(self.buffer_idx - len, self.buffer_idx); + return self.buffer.slice_mut(self.buffer_idx - len, self.buffer_idx); } fn full_buffer<'s>(&'s mut self) -> &'s [u8] { @@ -359,7 +359,7 @@ impl Engine256State { ) ) - read_u32v_be(w.mut_slice(0, 16), data); + read_u32v_be(w.slice_mut(0, 16), data); // Putting the message schedule inside the same loop as the round calculations allows for // the compiler to generate better code. @@ -495,14 +495,14 @@ impl Digest for Sha256 { fn result(&mut self, out: &mut [u8]) { self.engine.finish(); - write_u32_be(out.mut_slice(0, 4), self.engine.state.h0); - write_u32_be(out.mut_slice(4, 8), self.engine.state.h1); - write_u32_be(out.mut_slice(8, 12), self.engine.state.h2); - write_u32_be(out.mut_slice(12, 16), self.engine.state.h3); - write_u32_be(out.mut_slice(16, 20), self.engine.state.h4); - write_u32_be(out.mut_slice(20, 24), self.engine.state.h5); - write_u32_be(out.mut_slice(24, 28), self.engine.state.h6); - write_u32_be(out.mut_slice(28, 32), self.engine.state.h7); + write_u32_be(out.slice_mut(0, 4), self.engine.state.h0); + write_u32_be(out.slice_mut(4, 8), self.engine.state.h1); + write_u32_be(out.slice_mut(8, 12), self.engine.state.h2); + write_u32_be(out.slice_mut(12, 16), self.engine.state.h3); + write_u32_be(out.slice_mut(16, 20), self.engine.state.h4); + write_u32_be(out.slice_mut(20, 24), self.engine.state.h5); + write_u32_be(out.slice_mut(24, 28), self.engine.state.h6); + write_u32_be(out.slice_mut(28, 32), self.engine.state.h7); } fn reset(&mut self) { @@ -631,7 +631,7 @@ mod tests { let expected_vec: Vec = expected.from_hex() .unwrap() - .move_iter() + .into_iter() .collect(); assert_eq!(expected_vec, result_bytes); } diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 7272425761e02..ccff8afc50b03 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -52,7 +52,7 @@ pub fn try_inline(cx: &DocContext, id: ast::NodeId, into: Option) let did = def.def_id(); if ast_util::is_local(did) { return None } try_inline_def(cx, tcx, def).map(|vec| { - vec.move_iter().map(|mut item| { + vec.into_iter().map(|mut item| { match into { Some(into) if item.name.is_some() => { item.name = Some(into.clean(cx)); @@ -84,12 +84,12 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt, } def::DefStruct(did) => { record_extern_fqn(cx, did, clean::TypeStruct); - ret.extend(build_impls(cx, tcx, did).move_iter()); + ret.extend(build_impls(cx, tcx, did).into_iter()); clean::StructItem(build_struct(cx, tcx, did)) } def::DefTy(did) => { record_extern_fqn(cx, did, clean::TypeEnum); - ret.extend(build_impls(cx, tcx, did).move_iter()); + ret.extend(build_impls(cx, tcx, did).into_iter()); build_type(cx, tcx, did) } // Assume that the enum type is reexported next to the variant, and @@ -123,7 +123,7 @@ pub fn load_attrs(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> Vec { let mut attrs = Vec::new(); csearch::get_item_attrs(&tcx.sess.cstore, did, |v| { - attrs.extend(v.move_iter().map(|a| { + attrs.extend(v.into_iter().map(|a| { a.clean(cx) })); }); @@ -138,7 +138,7 @@ pub fn record_extern_fqn(cx: &DocContext, did: ast::DefId, kind: clean::TypeKind match cx.tcx_opt() { Some(tcx) => { let fqn = csearch::get_item_path(tcx, did); - let fqn = fqn.move_iter().map(|i| i.to_string()).collect(); + let fqn = fqn.into_iter().map(|i| i.to_string()).collect(); cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, kind)); } None => {} @@ -150,7 +150,7 @@ pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt, let def = ty::lookup_trait_def(tcx, did); let trait_items = ty::trait_items(tcx, did).clean(cx); let provided = ty::provided_trait_methods(tcx, did); - let mut items = trait_items.move_iter().map(|trait_item| { + let mut items = trait_items.into_iter().map(|trait_item| { if provided.iter().any(|a| a.def_id == trait_item.def_id) { clean::ProvidedMethod(trait_item) } else { @@ -262,7 +262,7 @@ fn build_impls(cx: &DocContext, tcx: &ty::ctxt, } } - impls.move_iter().filter_map(|a| a).collect() + impls.into_iter().filter_map(|a| a).collect() } fn build_impl(cx: &DocContext, tcx: &ty::ctxt, @@ -369,7 +369,7 @@ fn build_module(cx: &DocContext, tcx: &ty::ctxt, } decoder::DlDef(def) if vis == ast::Public => { match try_inline_def(cx, tcx, def) { - Some(i) => items.extend(i.move_iter()), + Some(i) => items.extend(i.into_iter()), None => {} } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index e6fcbbe9b6ff3..c42d8c79144dc 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -142,7 +142,7 @@ impl<'a, 'tcx> Clean for visit_ast::RustdocVisitor<'a, 'tcx> { _ => unreachable!(), }; let mut tmp = Vec::new(); - for child in m.items.mut_iter() { + for child in m.items.iter_mut() { let inner = match child.inner { ModuleItem(ref mut m) => m, _ => continue, @@ -171,7 +171,7 @@ impl<'a, 'tcx> Clean for visit_ast::RustdocVisitor<'a, 'tcx> { inner.items.push(i); } - m.items.extend(tmp.move_iter()); + m.items.extend(tmp.into_iter()); } Crate { @@ -333,8 +333,8 @@ impl Clean for doctree::Module { "".to_string() }; let mut foreigns = Vec::new(); - for subforeigns in self.foreigns.clean(cx).move_iter() { - for foreign in subforeigns.move_iter() { + for subforeigns in self.foreigns.clean(cx).into_iter() { + for foreign in subforeigns.into_iter() { foreigns.push(foreign) } } @@ -348,8 +348,8 @@ impl Clean for doctree::Module { self.statics.clean(cx), self.traits.clean(cx), self.impls.clean(cx), - self.view_items.clean(cx).move_iter() - .flat_map(|s| s.move_iter()).collect(), + self.view_items.clean(cx).into_iter() + .flat_map(|s| s.into_iter()).collect(), self.macros.clean(cx), ); @@ -538,7 +538,7 @@ impl Clean for ty::BuiltinBound { external_path(cx, "Sync", &empty)), }; let fqn = csearch::get_item_path(tcx, did); - let fqn = fqn.move_iter().map(|i| i.to_string()).collect(); + let fqn = fqn.into_iter().map(|i| i.to_string()).collect(); cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, TypeTrait)); TraitBound(ResolvedPath { @@ -556,7 +556,7 @@ impl Clean for ty::TraitRef { None => return RegionBound, }; let fqn = csearch::get_item_path(tcx, self.def_id); - let fqn = fqn.move_iter().map(|i| i.to_string()) + let fqn = fqn.into_iter().map(|i| i.to_string()) .collect::>(); let path = external_path(cx, fqn.last().unwrap().as_slice(), &self.substs); @@ -842,9 +842,9 @@ impl<'a> Clean for (ast::DefId, &'a ty::FnSig) { fn clean(&self, cx: &DocContext) -> FnDecl { let (did, sig) = *self; let mut names = if did.node != 0 { - csearch::get_method_arg_names(&cx.tcx().sess.cstore, did).move_iter() + csearch::get_method_arg_names(&cx.tcx().sess.cstore, did).into_iter() } else { - Vec::new().move_iter() + Vec::new().into_iter() }.peekable(); if names.peek().map(|s| s.as_slice()) == Some("self") { let _ = names.next(); @@ -1274,7 +1274,7 @@ impl Clean for ty::t { ty::ty_enum(did, ref substs) | ty::ty_trait(box ty::TyTrait { def_id: did, ref substs, .. }) => { let fqn = csearch::get_item_path(cx.tcx(), did); - let fqn: Vec = fqn.move_iter().map(|i| { + let fqn: Vec = fqn.into_iter().map(|i| { i.to_string() }).collect(); let kind = match ty::get(*self).sty { @@ -1739,7 +1739,7 @@ impl Clean for doctree::Impl { generics: self.generics.clean(cx), trait_: self.trait_.clean(cx), for_: self.for_.clean(cx), - items: self.items.clean(cx).move_iter().map(|ti| { + items: self.items.clean(cx).into_iter().map(|ti| { match ti { MethodImplItem(i) => i, } @@ -1789,7 +1789,7 @@ impl Clean> for ast::ViewItem { let remaining = list.iter().filter(|path| { match inline::try_inline(cx, path.node.id(), None) { Some(items) => { - ret.extend(items.move_iter()); false + ret.extend(items.into_iter()); false } None => true, } @@ -1804,7 +1804,7 @@ impl Clean> for ast::ViewItem { } ast::ViewPathSimple(ident, _, id) => { match inline::try_inline(cx, id, Some(ident)) { - Some(items) => ret.extend(items.move_iter()), + Some(items) => ret.extend(items.into_iter()), None => ret.push(convert(&self.node)), } } @@ -2131,7 +2131,7 @@ fn lang_struct(cx: &DocContext, did: Option, None => return fallback(box t.clean(cx)), }; let fqn = csearch::get_item_path(cx.tcx(), did); - let fqn: Vec = fqn.move_iter().map(|i| { + let fqn: Vec = fqn.into_iter().map(|i| { i.to_string() }).collect(); cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, TypeStruct)); diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index ddb4b994ca38e..c5aece4ceacb1 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -109,7 +109,7 @@ pub fn run_core(libs: Vec, cfgs: Vec, externs: Externs, span_diagnostic_handler); let mut cfg = config::build_configuration(&sess); - for cfg_ in cfgs.move_iter() { + for cfg_ in cfgs.into_iter() { let cfg_ = token::intern_and_get_ident(cfg_.as_slice()); cfg.push(P(codemap::dummy_spanned(ast::MetaWord(cfg_)))); } diff --git a/src/librustdoc/flock.rs b/src/librustdoc/flock.rs index 101f1c7460571..f05e8c7cd8bd2 100644 --- a/src/librustdoc/flock.rs +++ b/src/librustdoc/flock.rs @@ -192,10 +192,10 @@ mod imp { libc::FILE_SHARE_READ | libc::FILE_SHARE_DELETE | libc::FILE_SHARE_WRITE, - ptr::mut_null(), + ptr::null_mut(), libc::CREATE_ALWAYS, libc::FILE_ATTRIBUTE_NORMAL, - ptr::mut_null()) + ptr::null_mut()) }; if handle == libc::INVALID_HANDLE_VALUE { fail!("create file error: {}", os::last_os_error()); diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index f0082f8900e6a..66e93de995ee8 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -25,7 +25,7 @@ pub trait DocFolder { StructItem(mut i) => { let mut foo = Vec::new(); swap(&mut foo, &mut i.fields); let num_fields = foo.len(); - i.fields.extend(foo.move_iter().filter_map(|x| self.fold_item(x))); + i.fields.extend(foo.into_iter().filter_map(|x| self.fold_item(x))); i.fields_stripped |= num_fields != i.fields.len(); StructItem(i) }, @@ -35,7 +35,7 @@ pub trait DocFolder { EnumItem(mut i) => { let mut foo = Vec::new(); swap(&mut foo, &mut i.variants); let num_variants = foo.len(); - i.variants.extend(foo.move_iter().filter_map(|x| self.fold_item(x))); + i.variants.extend(foo.into_iter().filter_map(|x| self.fold_item(x))); i.variants_stripped |= num_variants != i.variants.len(); EnumItem(i) }, @@ -58,12 +58,12 @@ pub trait DocFolder { } } let mut foo = Vec::new(); swap(&mut foo, &mut i.items); - i.items.extend(foo.move_iter().filter_map(|x| vtrm(self, x))); + i.items.extend(foo.into_iter().filter_map(|x| vtrm(self, x))); TraitItem(i) }, ImplItem(mut i) => { let mut foo = Vec::new(); swap(&mut foo, &mut i.items); - i.items.extend(foo.move_iter() + i.items.extend(foo.into_iter() .filter_map(|x| self.fold_item(x))); ImplItem(i) }, @@ -74,7 +74,7 @@ pub trait DocFolder { let mut foo = Vec::new(); swap(&mut foo, &mut j.fields); let num_fields = foo.len(); let c = |x| self.fold_item(x); - j.fields.extend(foo.move_iter().filter_map(c)); + j.fields.extend(foo.into_iter().filter_map(c)); j.fields_stripped |= num_fields != j.fields.len(); VariantItem(Variant {kind: StructVariant(j), ..i2}) }, @@ -91,7 +91,7 @@ pub trait DocFolder { fn fold_mod(&mut self, m: Module) -> Module { Module { is_crate: m.is_crate, - items: m.items.move_iter().filter_map(|i| self.fold_item(i)).collect() + items: m.items.into_iter().filter_map(|i| self.fold_item(i)).collect() } } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 06346e0b6b918..169446b0ac077 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -299,7 +299,7 @@ pub fn run(mut krate: clean::Crate, external_html: &ExternalHtml, dst: Path) -> let paths: HashMap, ItemType)> = analysis.as_ref().map(|a| { let paths = a.external_paths.borrow_mut().take().unwrap(); - paths.move_iter().map(|(k, (v, t))| { + paths.into_iter().map(|(k, (v, t))| { (k, (v, match t { clean::TypeStruct => item_type::Struct, clean::TypeEnum => item_type::Enum, @@ -950,7 +950,7 @@ impl DocFolder for Cache { use clean::{FixedVector, Slice, Tuple, PrimitiveTuple}; // extract relevant documentation for this impl - let dox = match attrs.move_iter().find(|a| { + let dox = match attrs.into_iter().find(|a| { match *a { clean::NameValue(ref x, _) if "doc" == x.as_slice() => { @@ -1207,7 +1207,7 @@ impl Context { _ => unreachable!() }; this.sidebar = build_sidebar(&m); - for item in m.items.move_iter() { + for item in m.items.into_iter() { f(this,item); } Ok(()) @@ -2143,7 +2143,7 @@ fn build_sidebar(m: &clean::Module) -> HashMap> { v.push(myname); } - for (_, items) in map.mut_iter() { + for (_, items) in map.iter_mut() { items.as_mut_slice().sort(); } return map; diff --git a/src/librustdoc/html/toc.rs b/src/librustdoc/html/toc.rs index 45c75ccd1ab42..4d2f23e1c314e 100644 --- a/src/librustdoc/html/toc.rs +++ b/src/librustdoc/html/toc.rs @@ -167,7 +167,7 @@ impl TocBuilder { // get the thing we just pushed, so we can borrow the string // out of it with the right lifetime - let just_inserted = self.chain.mut_last().unwrap(); + let just_inserted = self.chain.last_mut().unwrap(); just_inserted.sec_number.as_slice() } } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 758af6758c2c4..f8eb40a389452 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -430,7 +430,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche pm.add_plugin(plugin); } info!("loading plugins..."); - for pname in plugins.move_iter() { + for pname in plugins.into_iter() { pm.load_plugin(pname); } @@ -494,7 +494,7 @@ fn json_output(krate: clean::Crate, res: Vec , // } let mut json = std::collections::TreeMap::new(); json.insert("schema".to_string(), json::String(SCHEMA_VERSION.to_string())); - let plugins_json = res.move_iter() + let plugins_json = res.into_iter() .filter_map(|opt| { match opt { None => None, diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index b7c602d9d730f..685d76bb5200b 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -65,7 +65,7 @@ pub fn run(input: &str, span_diagnostic_handler); let mut cfg = config::build_configuration(&sess); - cfg.extend(cfgs.move_iter().map(|cfg_| { + cfg.extend(cfgs.into_iter().map(|cfg_| { let cfg_ = token::intern_and_get_ident(cfg_.as_slice()); P(dummy_spanned(ast::MetaWord(cfg_))) })); @@ -104,7 +104,7 @@ pub fn run(input: &str, test_args.insert(0, "rustdoctest".to_string()); testing::test_main(test_args.as_slice(), - collector.tests.move_iter().collect()); + collector.tests.into_iter().collect()); 0 } diff --git a/src/librustrt/at_exit_imp.rs b/src/librustrt/at_exit_imp.rs index 8137669298124..8854c33b169f2 100644 --- a/src/librustrt/at_exit_imp.rs +++ b/src/librustrt/at_exit_imp.rs @@ -59,7 +59,7 @@ pub fn run() { v }; - for to_run in cur.move_iter() { + for to_run in cur.into_iter() { to_run(); } } diff --git a/src/librustrt/exclusive.rs b/src/librustrt/exclusive.rs index e5de2d195ebd6..d40f149a2a1f8 100644 --- a/src/librustrt/exclusive.rs +++ b/src/librustrt/exclusive.rs @@ -107,7 +107,7 @@ mod tests { }); }; - for f in futures.mut_iter() { f.recv() } + for f in futures.iter_mut() { f.recv() } assert_eq!(**total.lock(), num_tasks * count); } diff --git a/src/librustrt/local_heap.rs b/src/librustrt/local_heap.rs index 273505c416a3c..fe377d9e75b87 100644 --- a/src/librustrt/local_heap.rs +++ b/src/librustrt/local_heap.rs @@ -39,7 +39,7 @@ impl LocalHeap { pub fn new() -> LocalHeap { LocalHeap { memory_region: MemoryRegion { live_allocations: 0 }, - live_allocs: ptr::mut_null(), + live_allocs: ptr::null_mut(), } } @@ -58,7 +58,7 @@ impl LocalHeap { // allocations list mybox.drop_glue = drop_glue; mybox.ref_count = 1; - mybox.prev = ptr::mut_null(); + mybox.prev = ptr::null_mut(); mybox.next = self.live_allocs; if !self.live_allocs.is_null() { unsafe { (*self.live_allocs).prev = alloc; } @@ -165,7 +165,7 @@ impl LocalHeap { //! Walks the internal list of allocations let mut alloc = self.live_allocs; - while alloc != ptr::mut_null() { + while alloc != ptr::null_mut() { let next_before = (*alloc).next; f(self, alloc); diff --git a/src/librustrt/local_ptr.rs b/src/librustrt/local_ptr.rs index 8ce12a5157de3..92a67da20b656 100644 --- a/src/librustrt/local_ptr.rs +++ b/src/librustrt/local_ptr.rs @@ -282,7 +282,7 @@ pub mod native { rtabort!("thread-local pointer is null. bogus!"); } let ptr: Box = mem::transmute(void_ptr); - tls::set(key, ptr::mut_null()); + tls::set(key, ptr::null_mut()); return ptr; } @@ -300,7 +300,7 @@ pub mod native { None } else { let ptr: Box = mem::transmute(void_ptr); - tls::set(key, ptr::mut_null()); + tls::set(key, ptr::null_mut()); Some(ptr) } } diff --git a/src/librustrt/mutex.rs b/src/librustrt/mutex.rs index 3aa798aa92a20..f4fff43fd7c4f 100644 --- a/src/librustrt/mutex.rs +++ b/src/librustrt/mutex.rs @@ -615,7 +615,7 @@ mod imp { } pub unsafe fn init_cond() -> uint { - return CreateEventA(ptr::mut_null(), libc::FALSE, libc::FALSE, + return CreateEventA(ptr::null_mut(), libc::FALSE, libc::FALSE, ptr::null()) as uint; } diff --git a/src/librustrt/thread.rs b/src/librustrt/thread.rs index 6d18ec4f9f5ad..bef799d4178aa 100644 --- a/src/librustrt/thread.rs +++ b/src/librustrt/thread.rs @@ -171,8 +171,8 @@ mod imp { // kernel does, might as well make it explicit. With the current // 20 kB red zone, that makes for a 64 kB minimum stack. let stack_size = (cmp::max(stack, RED_ZONE) + 0xfffe) & (-0xfffe - 1); - let ret = CreateThread(ptr::mut_null(), stack_size as libc::size_t, - super::thread_start, arg, 0, ptr::mut_null()); + let ret = CreateThread(ptr::null_mut(), stack_size as libc::size_t, + super::thread_start, arg, 0, ptr::null_mut()); if ret as uint == 0 { // be sure to not leak the closure @@ -268,7 +268,7 @@ mod imp { } pub unsafe fn join(native: rust_thread) { - assert_eq!(pthread_join(native, ptr::mut_null()), 0); + assert_eq!(pthread_join(native, ptr::null_mut()), 0); } pub unsafe fn detach(native: rust_thread) { diff --git a/src/librustrt/util.rs b/src/librustrt/util.rs index 1334000ed1f5c..77e3e25eb0e7e 100644 --- a/src/librustrt/util.rs +++ b/src/librustrt/util.rs @@ -62,7 +62,7 @@ pub fn abort(args: &fmt::Arguments) -> ! { } impl<'a> FormatWriter for BufWriter<'a> { fn write(&mut self, bytes: &[u8]) -> fmt::Result { - let left = self.buf.mut_slice_from(self.pos); + let left = self.buf.slice_from_mut(self.pos); let to_write = bytes.slice_to(cmp::min(bytes.len(), left.len())); slice::bytes::copy_memory(left, to_write); self.pos += to_write.len(); diff --git a/src/librustuv/addrinfo.rs b/src/librustuv/addrinfo.rs index 8b41219db62f1..995f73af258ff 100644 --- a/src/librustuv/addrinfo.rs +++ b/src/librustuv/addrinfo.rs @@ -11,7 +11,7 @@ use libc::c_int; use libc; use std::mem; -use std::ptr::{null, mut_null}; +use std::ptr::{null, null_mut}; use std::rt::task::BlockedTask; use std::rt::rtio; @@ -62,9 +62,9 @@ impl GetAddrInfoRequest { ai_socktype: 0, ai_protocol: 0, ai_addrlen: 0, - ai_canonname: mut_null(), - ai_addr: mut_null(), - ai_next: mut_null(), + ai_canonname: null_mut(), + ai_addr: null_mut(), + ai_next: null_mut(), } }); let hint_ptr = hint.as_ref().map_or(null(), |x| { diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index abc55b67b3bc8..7cbfac1cf45d6 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -168,7 +168,7 @@ pub trait UvHandle { } unsafe { - uvll::set_data_for_uv_handle(self.uv_handle(), ptr::mut_null::<()>()); + uvll::set_data_for_uv_handle(self.uv_handle(), ptr::null_mut::<()>()); uvll::uv_close(self.uv_handle() as *mut uvll::uv_handle_t, close_cb) } } @@ -179,7 +179,7 @@ pub trait UvHandle { unsafe { uvll::uv_close(self.uv_handle() as *mut uvll::uv_handle_t, close_cb); uvll::set_data_for_uv_handle(self.uv_handle(), - ptr::mut_null::<()>()); + ptr::null_mut::<()>()); wait_until_woken_after(&mut slot, &self.uv_loop(), || { uvll::set_data_for_uv_handle(self.uv_handle(), &mut slot); @@ -190,7 +190,7 @@ pub trait UvHandle { unsafe { let data = uvll::get_data_for_uv_handle(handle); uvll::free_handle(handle); - if data == ptr::mut_null() { return } + if data == ptr::null_mut() { return } let slot: &mut Option = mem::transmute(data); wakeup(slot); } @@ -271,7 +271,7 @@ impl Request { pub fn new(ty: uvll::uv_req_type) -> Request { unsafe { let handle = uvll::malloc_req(ty); - uvll::set_data_for_req(handle, ptr::mut_null::<()>()); + uvll::set_data_for_req(handle, ptr::null_mut::<()>()); Request::wrap(handle) } } @@ -286,7 +286,7 @@ impl Request { pub unsafe fn get_data(&self) -> &'static mut T { let data = uvll::get_data_for_req(self.handle); - assert!(data != ptr::mut_null()); + assert!(data != ptr::null_mut()); mem::transmute(data) } @@ -448,7 +448,7 @@ pub type Buf = uvll::uv_buf_t; pub fn empty_buf() -> Buf { uvll::uv_buf_t { - base: ptr::mut_null(), + base: ptr::null_mut(), len: 0, } } diff --git a/src/librustuv/process.rs b/src/librustuv/process.rs index 4a12f959ad9a5..31c9fdde68cd0 100644 --- a/src/librustuv/process.rs +++ b/src/librustuv/process.rs @@ -60,7 +60,7 @@ impl Process { let mut ret_io = Vec::with_capacity(io.len()); unsafe { stdio.set_len(io.len()); - for (slot, other) in stdio.mut_iter().zip(io.iter()) { + for (slot, other) in stdio.iter_mut().zip(io.iter()) { let io = set_stdio(slot as *mut uvll::uv_stdio_container_t, other, io_loop); ret_io.push(io); diff --git a/src/librustuv/stream.rs b/src/librustuv/stream.rs index 12831002b65ec..97bd9315a0a5c 100644 --- a/src/librustuv/stream.rs +++ b/src/librustuv/stream.rs @@ -136,7 +136,7 @@ impl StreamWatcher { let mut req = match self.last_write_req.take() { Some(req) => req, None => Request::new(uvll::UV_WRITE), }; - req.set_data(ptr::mut_null::<()>()); + req.set_data(ptr::null_mut::<()>()); // And here's where timeouts get a little interesting. Currently, libuv // does not support canceling an in-flight write request. Consequently, diff --git a/src/librustuv/tty.rs b/src/librustuv/tty.rs index 70b17db8dcfdd..43973f2fb8e50 100644 --- a/src/librustuv/tty.rs +++ b/src/librustuv/tty.rs @@ -70,7 +70,7 @@ impl TtyWatcher { // handle, so our only cleanup is to free the handle itself if cfg!(windows) { unsafe { uvll::free_handle(handle); } - watcher.tty = ptr::mut_null(); + watcher.tty = ptr::null_mut(); } Err(UvError(n)) } diff --git a/src/librustuv/uvio.rs b/src/librustuv/uvio.rs index 30b172c5b6bf0..f2a2b5d2f1d3b 100644 --- a/src/librustuv/uvio.rs +++ b/src/librustuv/uvio.rs @@ -270,7 +270,7 @@ impl IoFactory for UvIoFactory { match Process::spawn(self, cfg) { Ok((p, io)) => { Ok((p as Box, - io.move_iter().map(|i| i.map(|p| { + io.into_iter().map(|i| i.map(|p| { box p as Box })).collect())) } diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index 1d2fcc8b77b15..5e8697ef0ade4 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -131,7 +131,7 @@ impl<'a> FromHex for &'a str { } match modulus { - 0 => Ok(b.move_iter().collect()), + 0 => Ok(b.into_iter().collect()), _ => Err(InvalidHexLength), } } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 733bc593922de..e9c3a2afb0386 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1843,7 +1843,7 @@ impl> Builder { loop { if self.token == Some(ListEnd) { - return Ok(List(values.move_iter().collect())); + return Ok(List(values.into_iter().collect())); } match self.build_value() { Ok(v) => values.push(v), @@ -2059,7 +2059,7 @@ impl ::Decoder for Decoder { }; match o.pop(&"fields".to_string()) { Some(List(l)) => { - for field in l.move_iter().rev() { + for field in l.into_iter().rev() { self.stack.push(field); } }, @@ -2186,7 +2186,7 @@ impl ::Decoder for Decoder { debug!("read_seq()"); let list = try!(expect!(self.pop(), List)); let len = list.len(); - for v in list.move_iter().rev() { + for v in list.into_iter().rev() { self.stack.push(v); } f(self, len) @@ -2203,7 +2203,7 @@ impl ::Decoder for Decoder { debug!("read_map()"); let obj = try!(expect!(self.pop(), Object)); let len = obj.len(); - for (key, value) in obj.move_iter() { + for (key, value) in obj.into_iter() { self.stack.push(value); self.stack.push(String(key)); } diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index f7b23163dfe48..fd8432ded8b50 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -464,7 +464,7 @@ impl<'a> AsciiExt> for &'a [u8] { impl OwnedAsciiExt for Vec { #[inline] fn into_ascii_upper(mut self) -> Vec { - for byte in self.mut_iter() { + for byte in self.iter_mut() { *byte = ASCII_UPPER_MAP[*byte as uint]; } self @@ -472,7 +472,7 @@ impl OwnedAsciiExt for Vec { #[inline] fn into_ascii_lower(mut self) -> Vec { - for byte in self.mut_iter() { + for byte in self.iter_mut() { *byte = ASCII_LOWER_MAP[*byte as uint]; } self diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 5f52c0ada5d62..d8a7305810fe4 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -73,7 +73,7 @@ impl CVec { /// * base - A raw pointer to a buffer /// * len - The number of elements in the buffer pub unsafe fn new(base: *mut T, len: uint) -> CVec { - assert!(base != ptr::mut_null()); + assert!(base != ptr::null_mut()); CVec { base: base, len: len, @@ -94,7 +94,7 @@ impl CVec { /// for freeing the buffer, etc. pub unsafe fn new_with_dtor(base: *mut T, len: uint, dtor: proc():Send) -> CVec { - assert!(base != ptr::mut_null()); + assert!(base != ptr::null_mut()); CVec { base: base, len: len, @@ -191,7 +191,7 @@ mod tests { #[should_fail] fn test_fail_at_null() { unsafe { - CVec::new(ptr::mut_null::(), 9); + CVec::new(ptr::null_mut::(), 9); } } diff --git a/src/libstd/collections/hashmap/map.rs b/src/libstd/collections/hashmap/map.rs index 4a58f4e75de70..e8c5eecc6f2e7 100644 --- a/src/libstd/collections/hashmap/map.rs +++ b/src/libstd/collections/hashmap/map.rs @@ -696,7 +696,7 @@ impl, V, S, H: Hasher> HashMap { if new_capacity < old_table.capacity() { // Shrink the table. Naive algorithm for resizing: - for (h, k, v) in old_table.move_iter() { + for (h, k, v) in old_table.into_iter() { self.insert_hashed_nocheck(h, k, v); } } else { @@ -943,7 +943,7 @@ impl, V, S, H: Hasher> HashMap { /// /// let new = vec!["a key", "b key", "z key"]; /// - /// for k in new.move_iter() { + /// for k in new.into_iter() { /// map.find_with_or_insert_with( /// k, "new value", /// // if the key does exist either prepend or append this @@ -1214,7 +1214,7 @@ impl, V, S, H: Hasher> HashMap { /// map.insert("c", 3); /// /// // Update all values - /// for (_, val) in map.mut_iter() { + /// for (_, val) in map.iter_mut() { /// *val *= 2; /// } /// @@ -1223,7 +1223,7 @@ impl, V, S, H: Hasher> HashMap { /// } /// ``` pub fn iter_mut(&mut self) -> MutEntries { - MutEntries { inner: self.table.mut_iter() } + MutEntries { inner: self.table.iter_mut() } } /// Deprecated: use `into_iter`. @@ -1247,11 +1247,11 @@ impl, V, S, H: Hasher> HashMap { /// map.insert("c", 3); /// /// // Not possible with .iter() - /// let vec: Vec<(&str, int)> = map.move_iter().collect(); + /// let vec: Vec<(&str, int)> = map.into_iter().collect(); /// ``` pub fn into_iter(self) -> MoveEntries { MoveEntries { - inner: self.table.move_iter().map(|(_, k, v)| (k, v)) + inner: self.table.into_iter().map(|(_, k, v)| (k, v)) } } } @@ -1573,7 +1573,7 @@ mod test_map { drop(hm.clone()); { - let mut half = hm.move_iter().take(50); + let mut half = hm.into_iter().take(50); let v = drop_vector.get().unwrap(); for i in range(0u, 200) { @@ -1797,7 +1797,7 @@ mod test_map { #[test] fn test_keys() { let vec = vec![(1i, 'a'), (2i, 'b'), (3i, 'c')]; - let map = vec.move_iter().collect::>(); + let map = vec.into_iter().collect::>(); let keys = map.keys().map(|&k| k).collect::>(); assert_eq!(keys.len(), 3); assert!(keys.contains(&1)); @@ -1808,7 +1808,7 @@ mod test_map { #[test] fn test_values() { let vec = vec![(1i, 'a'), (2i, 'b'), (3i, 'c')]; - let map = vec.move_iter().collect::>(); + let map = vec.into_iter().collect::>(); let values = map.values().map(|&v| v).collect::>(); assert_eq!(values.len(), 3); assert!(values.contains(&'a')); @@ -1997,7 +1997,7 @@ mod test_map { let mut map: HashMap = xs.iter().map(|&x| x).collect(); - let mut iter = map.mut_iter(); + let mut iter = map.iter_mut(); for _ in iter.by_ref().take(3) {} diff --git a/src/libstd/collections/hashmap/set.rs b/src/libstd/collections/hashmap/set.rs index 4a2a04cbc9f66..dde1f27c9a322 100644 --- a/src/libstd/collections/hashmap/set.rs +++ b/src/libstd/collections/hashmap/set.rs @@ -245,6 +245,12 @@ impl, S, H: Hasher> HashSet { self.map.keys() } + /// Deprecated: use `into_iter`. + #[deprecated = "use into_iter"] + pub fn move_iter(self) -> SetMoveItems { + self.into_iter() + } + /// Creates a consuming iterator, that is, one that moves each value out /// of the set in arbitrary order. The set cannot be used after calling /// this. @@ -258,15 +264,15 @@ impl, S, H: Hasher> HashSet { /// set.insert("b".to_string()); /// /// // Not possible to collect to a Vec with a regular `.iter()`. - /// let v: Vec = set.move_iter().collect(); + /// let v: Vec = set.into_iter().collect(); /// /// // Will print in an arbitrary order. /// for x in v.iter() { /// println!("{}", x); /// } /// ``` - pub fn move_iter(self) -> SetMoveItems { - self.map.move_iter().map(|(k, _)| k) + pub fn into_iter(self) -> SetMoveItems { + self.map.into_iter().map(|(k, _)| k) } /// Visit the values representing the difference. @@ -661,7 +667,7 @@ mod test_set { hs }; - let v = hs.move_iter().collect::>(); + let v = hs.into_iter().collect::>(); assert!(['a', 'b'] == v.as_slice() || ['b', 'a'] == v.as_slice()); } diff --git a/src/libstd/collections/hashmap/table.rs b/src/libstd/collections/hashmap/table.rs index 33e760f11cea4..87a5cc1484a24 100644 --- a/src/libstd/collections/hashmap/table.rs +++ b/src/libstd/collections/hashmap/table.rs @@ -872,7 +872,7 @@ impl Drop for RawTable { return; } // This is done in reverse because we've likely partially taken - // some elements out with `.move_iter()` from the front. + // some elements out with `.into_iter()` from the front. // Check if the size is 0, so we don't do a useless scan when // dropping empty tables such as on resize. // Also avoid double drop of elements that have been already moved out. diff --git a/src/libstd/collections/lru_cache.rs b/src/libstd/collections/lru_cache.rs index 32a16053fffcf..5408e50f2bda3 100644 --- a/src/libstd/collections/lru_cache.rs +++ b/src/libstd/collections/lru_cache.rs @@ -84,8 +84,8 @@ impl LruEntry { LruEntry { key: k, value: v, - next: ptr::mut_null(), - prev: ptr::mut_null(), + next: ptr::null_mut(), + prev: ptr::null_mut(), } } } diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index eee3e81f5fc06..e929f140dbd28 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -301,7 +301,7 @@ pub mod dl { } pub unsafe fn open_internal() -> *mut u8 { - let mut handle = ptr::mut_null(); + let mut handle = ptr::null_mut(); GetModuleHandleExW(0 as libc::DWORD, ptr::null(), &mut handle); handle as *mut u8 } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 76f86d66ff546..a777a372ad14f 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -195,7 +195,7 @@ impl Writer for BufferedWriter { if buf.len() > self.buf.len() { self.inner.get_mut_ref().write(buf) } else { - let dst = self.buf.mut_slice_from(self.pos); + let dst = self.buf.slice_from_mut(self.pos); slice::bytes::copy_memory(dst, buf); self.pos += buf.len(); Ok(()) @@ -273,7 +273,7 @@ impl InternalBufferedWriter { impl Reader for InternalBufferedWriter { fn read(&mut self, buf: &mut [u8]) -> IoResult { - self.get_mut_ref().inner.get_mut_ref().read(buf) + self.get_mut().inner.get_mut_ref().read(buf) } } @@ -359,10 +359,10 @@ impl Reader for BufferedStream { impl Writer for BufferedStream { fn write(&mut self, buf: &[u8]) -> IoResult<()> { - self.inner.inner.get_mut_ref().write(buf) + self.inner.inner.get_mut().write(buf) } fn flush(&mut self) -> IoResult<()> { - self.inner.inner.get_mut_ref().flush() + self.inner.inner.get_mut().flush() } } diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index 1c8b047f56f4d..f2ff5c7b5c2b4 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -62,7 +62,7 @@ impl Reader for ChanReader { loop { match self.buf { Some(ref prev) => { - let dst = buf.mut_slice_from(num_read); + let dst = buf.slice_from_mut(num_read); let src = prev.slice_from(self.pos); let count = cmp::min(dst.len(), src.len()); bytes::copy_memory(dst, src.slice_to(count)); diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index b7b7d1fb93d1a..f912b3ee38f10 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -652,7 +652,7 @@ pub fn rmdir(path: &Path) -> IoResult<()> { /// at a non-directory file pub fn readdir(path: &Path) -> IoResult> { let err = LocalIo::maybe_raise(|io| { - Ok(try!(io.fs_readdir(&path.to_c_str(), 0)).move_iter().map(|a| { + Ok(try!(io.fs_readdir(&path.to_c_str(), 0)).into_iter().map(|a| { Path::new(a) }).collect()) }).map_err(IoError::from_rtio_error); @@ -764,7 +764,7 @@ pub fn rmdir_recursive(path: &Path) -> IoResult<()> { // delete all regular files in the way and push subdirs // on the stack - for child in children.move_iter() { + for child in children.into_iter() { // FIXME(#12795) we should use lstat in all cases let child_type = match cfg!(windows) { true => try!(update_err(stat(&child), path)), @@ -1059,11 +1059,11 @@ mod test { { let mut read_stream = File::open_mode(filename, Open, Read); { - let read_buf = read_mem.mut_slice(0, 4); + let read_buf = read_mem.slice_mut(0, 4); check!(read_stream.read(read_buf)); } { - let read_buf = read_mem.mut_slice(4, 8); + let read_buf = read_mem.slice_mut(4, 8); check!(read_stream.read(read_buf)); } } diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 21ab9c1fdd431..c826bd16715d6 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -147,7 +147,7 @@ impl Reader for MemReader { let write_len = min(buf.len(), self.buf.len() - self.pos); { let input = self.buf.slice(self.pos, self.pos + write_len); - let output = buf.mut_slice(0, write_len); + let output = buf.slice_mut(0, write_len); assert_eq!(input.len(), output.len()); slice::bytes::copy_memory(output, input); } @@ -232,7 +232,7 @@ impl<'a> Writer for BufWriter<'a> { }) } - slice::bytes::copy_memory(self.buf.mut_slice_from(self.pos), buf); + slice::bytes::copy_memory(self.buf.slice_from_mut(self.pos), buf); self.pos += buf.len(); Ok(()) } @@ -293,7 +293,7 @@ impl<'a> Reader for BufReader<'a> { let write_len = min(buf.len(), self.buf.len() - self.pos); { let input = self.buf.slice(self.pos, self.pos + write_len); - let output = buf.mut_slice(0, write_len); + let output = buf.slice_mut(0, write_len); assert_eq!(input.len(), output.len()); slice::bytes::copy_memory(output, input); } @@ -548,7 +548,7 @@ mod test { assert!(r.read_at_least(buf.len(), buf).is_ok()); let b: &[_] = &[1, 2, 3]; assert_eq!(buf.as_slice(), b); - assert!(r.read_at_least(0, buf.mut_slice_to(0)).is_ok()); + assert!(r.read_at_least(0, buf.slice_to_mut(0)).is_ok()); assert_eq!(buf.as_slice(), b); assert!(r.read_at_least(buf.len(), buf).is_ok()); let b: &[_] = &[4, 5, 6]; diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 7a2bcab8706da..ff508c802d845 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -578,7 +578,7 @@ pub trait Reader { while read < min { let mut zeroes = 0; loop { - match self.read(buf.mut_slice_from(read)) { + match self.read(buf.slice_from_mut(read)) { Ok(0) => { zeroes += 1; if zeroes >= NO_PROGRESS_LIMIT { @@ -1524,7 +1524,7 @@ pub trait Buffer: Reader { { let mut start = 1; while start < width { - match try!(self.read(buf.mut_slice(start, width))) { + match try!(self.read(buf.slice_mut(start, width))) { n if n == width - start => break, n if n < width - start => { start += n; } _ => return Err(standard_error(InvalidInput)), diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs index 771eb9e13e836..867e8bcca826d 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/io/net/addrinfo.rs @@ -76,7 +76,7 @@ pub struct Info { /// Easy name resolution. Given a hostname, returns the list of IP addresses for /// that hostname. pub fn get_host_addresses(host: &str) -> IoResult> { - lookup(Some(host), None, None).map(|a| a.move_iter().map(|i| i.address.ip).collect()) + lookup(Some(host), None, None).map(|a| a.into_iter().map(|i| i.address.ip).collect()) } /// Full-fledged resolution. This function will perform a synchronous call to @@ -105,7 +105,7 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option) match LocalIo::maybe_raise(|io| { io.get_host_addresses(hostname, servname, hint) }) { - Ok(v) => Ok(v.move_iter().map(|info| { + Ok(v) => Ok(v.into_iter().map(|info| { Info { address: SocketAddr { ip: super::from_rtio(info.address.ip), diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index ed76cdc276ba6..1141cd22eebb6 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -109,7 +109,7 @@ impl<'a> Parser<'a> { // Return result of first successful parser fn read_or(&mut self, parsers: &mut [|&mut Parser| -> Option]) -> Option { - for pf in parsers.mut_iter() { + for pf in parsers.iter_mut() { match self.read_atomically(|p: &mut Parser| (*pf)(p)) { Some(r) => return Some(r), None => {} @@ -233,7 +233,7 @@ impl<'a> Parser<'a> { assert!(head.len() + tail.len() <= 8); let mut gs = [0u16, ..8]; gs.copy_from(head); - gs.mut_slice(8 - tail.len(), 8).copy_from(tail); + gs.slice_mut(8 - tail.len(), 8).copy_from(tail); Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7]) } diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 5f7563e7467ba..6689615f01b22 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -48,7 +48,7 @@ use rt::rtio; /// match socket.recv_from(buf) { /// Ok((amt, src)) => { /// // Send a reply to the socket we received data from -/// let buf = buf.mut_slice_to(amt); +/// let buf = buf.slice_to_mut(amt); /// buf.reverse(); /// socket.send_to(buf, src); /// } diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index c1f4161fe181f..1225dcf1f4a10 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -167,7 +167,7 @@ impl Command { None => { // if the env is currently just inheriting from the parent's, // materialize the parent's env into a hashtable. - self.env = Some(os::env_as_bytes().move_iter() + self.env = Some(os::env_as_bytes().into_iter() .map(|(k, v)| (k.as_slice().to_c_str(), v.as_slice().to_c_str())) .collect()); @@ -289,7 +289,7 @@ impl Command { detach: self.detach, }; io.spawn(cfg).map(|(p, io)| { - let mut io = io.move_iter().map(|p| { + let mut io = io.into_iter().map(|p| { p.map(|p| io::PipeStream::new(p)) }); Process { diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index 769ad2a8468d9..78d1a2f485afb 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -166,7 +166,7 @@ mod darwin_fd_limit { pub unsafe fn raise_fd_limit() { // The strategy here is to fetch the current resource limits, read the kern.maxfilesperproc // sysctl value, and bump the soft resource limit for maxfiles up to the sysctl value. - use ptr::mut_null; + use ptr::null_mut; use mem::size_of_val; use os::last_os_error; @@ -175,7 +175,7 @@ mod darwin_fd_limit { let mut maxfiles: libc::c_int = 0; let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t; if sysctl(&mut mib[0], 2, &mut maxfiles as *mut libc::c_int as *mut libc::c_void, &mut size, - mut_null(), 0) != 0 { + null_mut(), 0) != 0 { let err = last_os_error(); fail!("raise_fd_limit: error calling sysctl: {}", err); } diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 7fba0bc85a6b9..16ac8c4c265fe 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -47,7 +47,7 @@ impl Reader for LimitReader { } let len = cmp::min(self.limit, buf.len()); - let res = self.inner.read(buf.mut_slice_to(len)); + let res = self.inner.read(buf.slice_to_mut(len)); match res { Ok(len) => self.limit -= len, _ => {} @@ -139,7 +139,7 @@ impl MultiWriter { impl Writer for MultiWriter { #[inline] fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { - for writer in self.writers.mut_iter() { + for writer in self.writers.iter_mut() { try!(writer.write(buf)); } Ok(()) @@ -147,7 +147,7 @@ impl Writer for MultiWriter { #[inline] fn flush(&mut self) -> io::IoResult<()> { - for writer in self.writers.mut_iter() { + for writer in self.writers.iter_mut() { try!(writer.flush()); } Ok(()) @@ -251,7 +251,7 @@ impl> Reader for IterReader { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::IoResult { let mut len = 0; - for (slot, elt) in buf.mut_iter().zip(self.iter.by_ref()) { + for (slot, elt) in buf.iter_mut().zip(self.iter.by_ref()) { *slot = elt; len += 1; } @@ -364,7 +364,7 @@ mod test { fn test_chained_reader() { let rs = vec!(MemReader::new(vec!(0, 1)), MemReader::new(vec!()), MemReader::new(vec!(2, 3))); - let mut r = ChainedReader::new(rs.move_iter()); + let mut r = ChainedReader::new(rs.into_iter()); assert_eq!(vec!(0, 1, 2, 3), r.read_to_end().unwrap()); } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index ea278d55db956..f1480eb7d455a 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -218,7 +218,7 @@ fn with_env_lock(f: || -> T) -> T { /// } /// ``` pub fn env() -> Vec<(String,String)> { - env_as_bytes().move_iter().map(|(k,v)| { + env_as_bytes().into_iter().map(|(k,v)| { let k = String::from_utf8_lossy(k.as_slice()).into_string(); let v = String::from_utf8_lossy(v.as_slice()).into_string(); (k,v) @@ -663,14 +663,14 @@ pub fn self_exe_name() -> Option { -1 as c_int]; let mut sz: libc::size_t = 0; let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, - ptr::mut_null(), &mut sz, ptr::mut_null(), + ptr::null_mut(), &mut sz, ptr::null_mut(), 0u as libc::size_t); if err != 0 { return None; } if sz == 0 { return None; } let mut v: Vec = Vec::with_capacity(sz as uint); let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, v.as_mut_ptr() as *mut c_void, &mut sz, - ptr::mut_null(), 0u as libc::size_t); + ptr::null_mut(), 0u as libc::size_t); if err != 0 { return None; } if sz == 0 { return None; } v.set_len(sz as uint - 1); // chop off trailing NUL @@ -695,7 +695,7 @@ pub fn self_exe_name() -> Option { unsafe { use libc::funcs::extra::_NSGetExecutablePath; let mut sz: u32 = 0; - _NSGetExecutablePath(ptr::mut_null(), &mut sz); + _NSGetExecutablePath(ptr::null_mut(), &mut sz); if sz == 0 { return None; } let mut v: Vec = Vec::with_capacity(sz as uint); let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz); @@ -1045,7 +1045,7 @@ pub fn error_string(errnum: uint) -> String { unsafe { let res = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - ptr::mut_null(), + ptr::null_mut(), errnum as DWORD, langId, buf.as_mut_ptr(), @@ -1192,7 +1192,7 @@ fn real_args_as_bytes() -> Vec> { #[cfg(not(windows))] fn real_args() -> Vec { - real_args_as_bytes().move_iter() + real_args_as_bytes().into_iter() .map(|v| { String::from_utf8_lossy(v.as_slice()).into_string() }).collect() @@ -1229,7 +1229,7 @@ fn real_args() -> Vec { #[cfg(windows)] fn real_args_as_bytes() -> Vec> { - real_args().move_iter().map(|s| s.into_bytes()).collect() + real_args().into_iter().map(|s| s.into_bytes()).collect() } type LPCWSTR = *const u16; @@ -1529,7 +1529,7 @@ impl MemoryMap { pub fn new(min_len: uint, options: &[MapOption]) -> Result { use libc::types::os::arch::extra::{LPVOID, DWORD, SIZE_T, HANDLE}; - let mut lpAddress: LPVOID = ptr::mut_null(); + let mut lpAddress: LPVOID = ptr::null_mut(); let mut readable = false; let mut writable = false; let mut executable = false; @@ -1589,12 +1589,12 @@ impl MemoryMap { unsafe { let hFile = libc::get_osfhandle(fd) as HANDLE; let mapping = libc::CreateFileMappingW(hFile, - ptr::mut_null(), + ptr::null_mut(), flProtect, 0, 0, ptr::null()); - if mapping == ptr::mut_null() { + if mapping == ptr::null_mut() { return Err(ErrCreateFileMappingW(errno())); } if errno() as c_int == libc::ERROR_ALREADY_EXISTS { diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 06eab31d7bff5..c654d3a668a7c 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -382,7 +382,7 @@ impl Path { let n = if is_abs { comps.len() } else { comps.len() - 1} + comps.iter().map(|v| v.len()).sum(); let mut v = Vec::with_capacity(n); - let mut it = comps.move_iter(); + let mut it = comps.into_iter(); if !is_abs { match it.next() { None => (), @@ -1201,7 +1201,7 @@ mod tests { assert!(comps == exps, "components: Expected {:?}, found {:?}", comps, exps); let comps = path.components().rev().collect::>(); - let exps = exps.move_iter().rev().collect::>(); + let exps = exps.into_iter().rev().collect::>(); assert!(comps == exps, "rev_components: Expected {:?}, found {:?}", comps, exps); } diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index d9864cfaa6130..e68c8bdb07d20 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -832,7 +832,7 @@ impl Path { Some(_) => s.push_str(prefix_), None => () } - let mut it = comps.move_iter(); + let mut it = comps.into_iter(); if !is_abs { match it.next() { None => (), diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index b9b7a02b62f1b..4b3ddc2f95332 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -162,7 +162,7 @@ //! // where the car is. The game host will never open the door with the car. //! fn game_host_open(car: uint, choice: uint, rng: &mut R) -> uint { //! let choices = free_doors(&[car, choice]); -//! rand::sample(rng, choices.move_iter(), 1)[0] +//! rand::sample(rng, choices.into_iter(), 1)[0] //! } //! //! // Returns the door we switch to, given our current choice and diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index c28b6c144a251..5557ef9943b86 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -485,7 +485,7 @@ mod imp { let bytes = path.as_vec(); if bytes.len() < LAST_FILENAME.len() { let i = bytes.iter(); - for (slot, val) in LAST_FILENAME.mut_iter().zip(i) { + for (slot, val) in LAST_FILENAME.iter_mut().zip(i) { *slot = *val as libc::c_char; } LAST_FILENAME.as_ptr() @@ -496,7 +496,7 @@ mod imp { None => ptr::null(), }; STATE = backtrace_create_state(filename, 0, error_cb, - ptr::mut_null()); + ptr::null_mut()); return STATE } diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs index da0c3daefe705..23ba582ec0aa7 100644 --- a/src/libstd/sync/task_pool.rs +++ b/src/libstd/sync/task_pool.rs @@ -31,7 +31,7 @@ pub struct TaskPool { #[unsafe_destructor] impl Drop for TaskPool { fn drop(&mut self) { - for channel in self.channels.mut_iter() { + for channel in self.channels.iter_mut() { channel.send(Quit); } } diff --git a/src/libsync/comm/mod.rs b/src/libsync/comm/mod.rs index e46f52b3ad7b9..4e66dd69a607b 100644 --- a/src/libsync/comm/mod.rs +++ b/src/libsync/comm/mod.rs @@ -654,7 +654,7 @@ impl Sender { unsafe { let tmp = Sender::new(Stream(new_inner)); - mem::swap(self.mut_inner(), tmp.mut_inner()); + mem::swap(self.inner_mut(), tmp.inner_mut()); } return ret; } @@ -695,7 +695,7 @@ impl Clone for Sender { (*packet.get()).inherit_blocker(sleeper); let tmp = Sender::new(Shared(packet.clone())); - mem::swap(self.mut_inner(), tmp.mut_inner()); + mem::swap(self.inner_mut(), tmp.inner_mut()); } Sender::new(Shared(packet)) } @@ -704,7 +704,7 @@ impl Clone for Sender { #[unsafe_destructor] impl Drop for Sender { fn drop(&mut self) { - match *unsafe { self.mut_inner() } { + match *unsafe { self.inner_mut() } { Oneshot(ref mut p) => unsafe { (*p.get()).drop_chan(); }, Stream(ref mut p) => unsafe { (*p.get()).drop_chan(); }, Shared(ref mut p) => unsafe { (*p.get()).drop_chan(); }, @@ -895,8 +895,8 @@ impl Receiver { } }; unsafe { - mem::swap(self.mut_inner(), - new_port.mut_inner()); + mem::swap(self.inner_mut(), + new_port.inner_mut()); } } } @@ -943,7 +943,7 @@ impl Receiver { Sync(ref p) => return unsafe { (*p.get()).recv() } }; unsafe { - mem::swap(self.mut_inner(), new_port.mut_inner()); + mem::swap(self.inner_mut(), new_port.inner_mut()); } } } @@ -980,8 +980,8 @@ impl select::Packet for Receiver { } }; unsafe { - mem::swap(self.mut_inner(), - new_port.mut_inner()); + mem::swap(self.inner_mut(), + new_port.inner_mut()); } } } @@ -1012,8 +1012,8 @@ impl select::Packet for Receiver { }; task = t; unsafe { - mem::swap(self.mut_inner(), - new_port.mut_inner()); + mem::swap(self.inner_mut(), + new_port.inner_mut()); } } } @@ -1036,8 +1036,8 @@ impl select::Packet for Receiver { let new_port = match result { Ok(b) => return b, Err(p) => p }; was_upgrade = true; unsafe { - mem::swap(self.mut_inner(), - new_port.mut_inner()); + mem::swap(self.inner_mut(), + new_port.inner_mut()); } } } @@ -1051,7 +1051,7 @@ impl<'a, T: Send> Iterator for Messages<'a, T> { #[unsafe_destructor] impl Drop for Receiver { fn drop(&mut self) { - match *unsafe { self.mut_inner() } { + match *unsafe { self.inner_mut() } { Oneshot(ref mut p) => unsafe { (*p.get()).drop_port(); }, Stream(ref mut p) => unsafe { (*p.get()).drop_port(); }, Shared(ref mut p) => unsafe { (*p.get()).drop_port(); }, diff --git a/src/libsync/deque.rs b/src/libsync/deque.rs index 521a7d0bd73d7..6204b54fba4be 100644 --- a/src/libsync/deque.rs +++ b/src/libsync/deque.rs @@ -513,7 +513,7 @@ mod tests { } } - for thread in threads.move_iter() { + for thread in threads.into_iter() { thread.join(); } } @@ -536,7 +536,7 @@ mod tests { }) }).collect::>>(); - for thread in threads.move_iter() { + for thread in threads.into_iter() { thread.join(); } } @@ -592,7 +592,7 @@ mod tests { DONE.store(true, SeqCst); } - for thread in threads.move_iter() { + for thread in threads.into_iter() { thread.join(); } @@ -657,7 +657,7 @@ mod tests { unsafe { DONE.store(true, SeqCst); } - for thread in threads.move_iter() { + for thread in threads.into_iter() { thread.join(); } } diff --git a/src/libsync/lock.rs b/src/libsync/lock.rs index 08421d24fbbff..951a945f73a78 100644 --- a/src/libsync/lock.rs +++ b/src/libsync/lock.rs @@ -636,7 +636,7 @@ mod tests { } // Wait for children to pass their asserts - for r in children.mut_iter() { + for r in children.iter_mut() { assert!(r.get_ref().is_ok()); } @@ -722,12 +722,12 @@ mod tests { assert_eq!(*lock, 42); *lock = 31337; // send to other readers - for &(ref mut rc, _) in reader_convos.mut_iter() { + for &(ref mut rc, _) in reader_convos.iter_mut() { rc.send(()) } let lock = lock.downgrade(); // complete handshake with other readers - for &(_, ref mut rp) in reader_convos.mut_iter() { + for &(_, ref mut rp) in reader_convos.iter_mut() { rp.recv() } tx1.send(()); // tell writer to try again diff --git a/src/libsync/mpmc_bounded_queue.rs b/src/libsync/mpmc_bounded_queue.rs index 949ef3bc34c25..fa29bb6088ae1 100644 --- a/src/libsync/mpmc_bounded_queue.rs +++ b/src/libsync/mpmc_bounded_queue.rs @@ -210,7 +210,7 @@ mod tests { }); } - for rx in completion_rxs.mut_iter() { + for rx in completion_rxs.iter_mut() { assert_eq!(nmsgs, rx.recv()); } for _ in range(0, nthreads) { diff --git a/src/libsync/raw.rs b/src/libsync/raw.rs index b259eb7e579ec..81ae8dbb98f1a 100644 --- a/src/libsync/raw.rs +++ b/src/libsync/raw.rs @@ -804,14 +804,14 @@ mod tests { } // wait until all children get in the mutex - for rx in rxs.mut_iter() { rx.recv(); } + for rx in rxs.iter_mut() { rx.recv(); } { let lock = m.lock(); let num_woken = lock.cond.broadcast(); assert_eq!(num_woken, num_waiters); } // wait until all children wake up - for rx in rxs.mut_iter() { rx.recv(); } + for rx in rxs.iter_mut() { rx.recv(); } } #[test] fn test_mutex_cond_broadcast() { @@ -1058,13 +1058,13 @@ mod tests { } // wait until all children get in the mutex - for rx in rxs.mut_iter() { let _ = rx.recv(); } + for rx in rxs.iter_mut() { let _ = rx.recv(); } lock_cond(&x, |cond| { let num_woken = cond.broadcast(); assert_eq!(num_woken, num_waiters); }); // wait until all children wake up - for rx in rxs.mut_iter() { let _ = rx.recv(); } + for rx in rxs.iter_mut() { let _ = rx.recv(); } } #[test] fn test_rwlock_cond_broadcast() { diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 20594a428481e..ed0b8700bf374 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -417,7 +417,7 @@ impl<'ast> Map<'ast> { fn path_to_str_with_ident(&self, id: NodeId, i: Ident) -> String { self.with_path(id, |path| { - path_to_string(path.chain(Some(PathName(i.name)).move_iter())) + path_to_string(path.chain(Some(PathName(i.name)).into_iter())) }) } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 80e4d148bdec8..ace1e1245c718 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -245,14 +245,14 @@ pub fn last_meta_item_value_str_by_name(items: &[P], name: &str) pub fn sort_meta_items(items: Vec>) -> Vec> { // This is sort of stupid here, but we need to sort by // human-readable strings. - let mut v = items.move_iter() + let mut v = items.into_iter() .map(|mi| (mi.name(), mi)) .collect::)>>(); v.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b)); // There doesn't seem to be a more optimal way to do this - v.move_iter().map(|(_, m)| m.map(|Spanned {node, span}| { + v.into_iter().map(|(_, m)| m.map(|Spanned {node, span}| { Spanned { node: match node { MetaList(n, mis) => MetaList(n, sort_meta_items(mis)), diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 6e25b6b73ade6..773daa4a4c593 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -712,7 +712,7 @@ impl SyntaxEnv { } fn find_escape_frame<'a>(&'a mut self) -> &'a mut MapChainFrame { - for (i, frame) in self.chain.mut_iter().enumerate().rev() { + for (i, frame) in self.chain.iter_mut().enumerate().rev() { if !frame.info.macros_escape || i == 0 { return frame } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index eda373c4fb806..7b2613d4e8ba0 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -301,7 +301,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { types: Vec> ) -> ast::Path { let last_identifier = idents.pop().unwrap(); - let mut segments: Vec = idents.move_iter() + let mut segments: Vec = idents.into_iter() .map(|ident| { ast::PathSegment { identifier: ident, @@ -969,7 +969,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn variant(&self, span: Span, name: Ident, tys: Vec> ) -> ast::Variant { - let args = tys.move_iter().map(|ty| { + let args = tys.into_iter().map(|ty| { ast::VariantArg { ty: ty, id: ast::DUMMY_NODE_ID } }).collect(); diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs index 455148bfedd50..cd3e247a80697 100644 --- a/src/libsyntax/ext/concat.rs +++ b/src/libsyntax/ext/concat.rs @@ -25,7 +25,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, None => return base::DummyResult::expr(sp) }; let mut accumulator = String::new(); - for e in es.move_iter() { + for e in es.into_iter() { match e.node { ast::ExprLit(ref lit) => { match lit.node { diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 98c8885f7fa01..ecee2008254dd 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -26,7 +26,7 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, cs_same_method(|cx, span, exprs| { // create `a.(); b.(); c.(); ...` // (where method is `assert_receiver_is_total_eq`) - let stmts = exprs.move_iter().map(|e| cx.stmt_expr(e)).collect(); + let stmts = exprs.into_iter().map(|e| cx.stmt_expr(e)).collect(); let block = cx.block(span, stmts, None); cx.expr_block(block) }, diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 53af5a86ed2c6..ff249495bd7fd 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -468,7 +468,7 @@ impl<'a> TraitDef<'a> { ast::ItemImpl(trait_generics, opt_trait_ref, self_type, - methods.move_iter() + methods.into_iter() .map(|method| { ast::MethodImplItem(method) }).collect())) @@ -666,10 +666,10 @@ impl<'a> MethodDef<'a> { _ => Some(ast::Arg::new_self(trait_.span, ast::MutImmutable, special_idents::self_)) }; let args = { - let args = arg_types.move_iter().map(|(name, ty)| { + let args = arg_types.into_iter().map(|(name, ty)| { cx.arg(trait_.span, name, ty) }); - self_arg.move_iter().chain(args).collect() + self_arg.into_iter().chain(args).collect() }; let ret_type = self.get_ret_ty(cx, trait_, generics, type_ident); @@ -741,7 +741,7 @@ impl<'a> MethodDef<'a> { // transpose raw_fields let fields = if raw_fields.len() > 0 { - let mut raw_fields = raw_fields.move_iter().map(|v| v.move_iter()); + let mut raw_fields = raw_fields.into_iter().map(|v| v.into_iter()); let first_field = raw_fields.next().unwrap(); let mut other_fields: Vec, P)>> = raw_fields.collect(); @@ -750,7 +750,7 @@ impl<'a> MethodDef<'a> { span: span, name: opt_id, self_: field, - other: other_fields.mut_iter().map(|l| { + other: other_fields.iter_mut().map(|l| { match l.next().unwrap() { (_, _, ex) => ex } @@ -953,7 +953,7 @@ impl<'a> MethodDef<'a> { // The transposition is driven by walking across the // arg fields of the variant for the first self pat. - let field_tuples = first_self_pat_idents.move_iter().enumerate() + let field_tuples = first_self_pat_idents.into_iter().enumerate() // For each arg field of self, pull out its getter expr ... .map(|(field_index, (sp, opt_ident, self_getter_expr))| { // ... but FieldInfo also wants getter expr @@ -1264,7 +1264,7 @@ impl<'a> TraitDef<'a> { // struct_type is definitely not Unknown, since struct_def.fields // must be nonempty to reach here let pattern = if struct_type == Record { - let field_pats = subpats.move_iter().zip(ident_expr.iter()).map(|(pat, &(_, id, _))| { + let field_pats = subpats.into_iter().zip(ident_expr.iter()).map(|(pat, &(_, id, _))| { // id is guaranteed to be Some ast::FieldPat { ident: id.unwrap(), pat: pat } }).collect(); @@ -1418,11 +1418,11 @@ pub fn cs_same_method_fold(use_foldl: bool, cs_same_method( |cx, span, vals| { if use_foldl { - vals.move_iter().fold(base.clone(), |old, new| { + vals.into_iter().fold(base.clone(), |old, new| { f(cx, span, old, new) }) } else { - vals.move_iter().rev().fold(base.clone(), |old, new| { + vals.into_iter().rev().fold(base.clone(), |old, new| { f(cx, span, old, new) }) } diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 69574ee669678..87e257c52cd25 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -67,7 +67,7 @@ pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) return DummyResult::expr(sp); } None => return DummyResult::expr(sp), - Some(exprs) => exprs.move_iter() + Some(exprs) => exprs.into_iter() }; let var = match expr_to_string(cx, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 310f7c4f3036f..4ff9912645aa0 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -271,8 +271,8 @@ pub fn expand_item(it: P, fld: &mut MacroExpander) let mut items: SmallVector> = SmallVector::zero(); dec.expand(fld.cx, attr.span, &*attr.node.value, &*it, |item| items.push(item)); - decorator_items.extend(items.move_iter() - .flat_map(|item| expand_item(item, fld).move_iter())); + decorator_items.extend(items.into_iter() + .flat_map(|item| expand_item(item, fld).into_iter())); fld.cx.bt_pop(); } @@ -485,9 +485,9 @@ pub fn expand_item_mac(it: P, fld: &mut MacroExpander) SmallVector::zero() } Right(Some(items)) => { - items.move_iter() + items.into_iter() .map(|i| mark_item(i, fm)) - .flat_map(|i| fld.fold_item(i).move_iter()) + .flat_map(|i| fld.fold_item(i).into_iter()) .collect() } Right(None) => { @@ -525,7 +525,7 @@ fn expand_stmt(s: Stmt, fld: &mut MacroExpander) -> SmallVector> { fld.cx.bt_pop(); if semi { - fully_expanded.move_iter().map(|s| s.map(|Spanned {node, span}| { + fully_expanded.into_iter().map(|s| s.map(|Spanned {node, span}| { Spanned { node: match node { StmtExpr(e, stmt_id) => StmtSemi(e, stmt_id), @@ -620,7 +620,7 @@ fn expand_arm(arm: ast::Arm, fld: &mut MacroExpander) -> ast::Arm { // all of the pats must have the same set of bindings, so use the // first one to extract them and generate new names: let idents = pattern_bindings(&**expanded_pats.get(0)); - let new_renames = idents.move_iter().map(|id| (id, fresh_name(&id))).collect(); + let new_renames = idents.into_iter().map(|id| (id, fresh_name(&id))).collect(); // apply the renaming, but only to the PatIdents: let mut rename_pats_fld = PatIdentRenamer{renames:&new_renames}; let rewritten_pats = expanded_pats.move_map(|pat| rename_pats_fld.fold_pat(pat)); @@ -687,8 +687,8 @@ pub fn expand_block(blk: P, fld: &mut MacroExpander) -> P { // expand the elements of a block. pub fn expand_block_elts(b: P, fld: &mut MacroExpander) -> P { b.map(|Block {id, view_items, stmts, expr, rules, span}| { - let new_view_items = view_items.move_iter().map(|x| fld.fold_view_item(x)).collect(); - let new_stmts = stmts.move_iter().flat_map(|x| { + let new_view_items = view_items.into_iter().map(|x| fld.fold_view_item(x)).collect(); + let new_stmts = stmts.into_iter().flat_map(|x| { // perform all pending renames let renamed_stmt = { let pending_renames = &mut fld.cx.syntax_env.info().pending_renames; @@ -696,7 +696,7 @@ pub fn expand_block_elts(b: P, fld: &mut MacroExpander) -> P { rename_fld.fold_stmt(x).expect_one("rename_fold didn't return one value") }; // expand macros in the statement - fld.fold_stmt(renamed_stmt).move_iter() + fld.fold_stmt(renamed_stmt).into_iter() }).collect(); let new_expr = expr.map(|x| { let expr = { @@ -897,7 +897,7 @@ fn expand_method(m: P, fld: &mut MacroExpander) -> SmallVector", token::get_ident(crate_name)) .into_string(); - for source in macros.move_iter() { + for source in macros.into_iter() { let item = parse::parse_item_from_source_str(name.clone(), source, expander.cx.cfg(), @@ -1008,7 +1008,7 @@ pub fn expand_crate(parse_sess: &parse::ParseSess, } } - for (name, extension) in user_exts.move_iter() { + for (name, extension) in user_exts.into_iter() { expander.cx.syntax_env.insert(name, extension); } diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 271a5137bbf36..2658668430976 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -500,7 +500,7 @@ impl<'a, 'b> Context<'a, 'b> { let mut heads = Vec::new(); // First, declare all of our methods that are statics - for method in self.method_statics.move_iter() { + for method in self.method_statics.into_iter() { let decl = respan(self.fmtsp, ast::DeclItem(method)); lets.push(P(respan(self.fmtsp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))); @@ -543,7 +543,7 @@ impl<'a, 'b> Context<'a, 'b> { // format! string are shoved into locals. Furthermore, we shove the address // of each variable because we don't want to move out of the arguments // passed to this function. - for (i, e) in self.args.move_iter().enumerate() { + for (i, e) in self.args.into_iter().enumerate() { let arg_ty = match self.arg_types.get(i).as_ref() { Some(ty) => ty, None => continue // error already generated @@ -577,8 +577,8 @@ impl<'a, 'b> Context<'a, 'b> { // Now create a vector containing all the arguments let slicename = self.ecx.ident_of("__args_vec"); { - let args = names.move_iter().map(|a| a.unwrap()); - let mut args = locals.move_iter().chain(args); + let args = names.into_iter().map(|a| a.unwrap()); + let mut args = locals.into_iter().chain(args); let args = self.ecx.expr_vec_slice(self.fmtsp, args.collect()); lets.push(self.ecx.stmt_let(self.fmtsp, false, slicename, args)); } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 6f13a2e6a51fc..aa2a23dd2768a 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -54,7 +54,7 @@ pub mod rt { impl ToTokens for Vec { fn to_tokens(&self, cx: &ExtCtxt) -> Vec { - let a = self.iter().flat_map(|t| t.to_tokens(cx).move_iter()); + let a = self.iter().flat_map(|t| t.to_tokens(cx).into_iter()); FromIterator::from_iter(a) } } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 3006bcaf6f876..090b39eee4714 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -366,7 +366,7 @@ pub fn parse(sess: &ParseSess, if token_name_eq(&tok, &EOF) { if eof_eis.len() == 1u { let mut v = Vec::new(); - for dv in eof_eis.get_mut(0).matches.mut_iter() { + for dv in eof_eis.get_mut(0).matches.iter_mut() { v.push(dv.pop().unwrap()); } return Success(nameize(sess, ms, v.as_slice())); diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 726a7315f6991..1b9f6f16542f2 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -164,7 +164,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { /* done with this set; pop or repeat? */ if should_pop { let prev = r.stack.pop().unwrap(); - match r.stack.mut_last() { + match r.stack.last_mut() { None => { r.cur_tok = EOF; return ret_val; @@ -178,8 +178,8 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { r.repeat_len.pop(); } } else { /* repeat */ - *r.repeat_idx.mut_last().unwrap() += 1u; - r.stack.mut_last().unwrap().idx = 0; + *r.repeat_idx.last_mut().unwrap() += 1u; + r.stack.last_mut().unwrap().idx = 0; match r.stack.last().unwrap().sep.clone() { Some(tk) => { r.cur_tok = tk; /* repeat same span, I guess */ @@ -209,7 +209,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { TTTok(sp, tok) => { r.cur_span = sp; r.cur_tok = tok; - r.stack.mut_last().unwrap().idx += 1; + r.stack.last_mut().unwrap().idx += 1; return ret_val; } TTSeq(sp, tts, sep, zerok) => { @@ -234,7 +234,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { "this must repeat at least once"); } - r.stack.mut_last().unwrap().idx += 1; + r.stack.last_mut().unwrap().idx += 1; return tt_next_token(r); } r.repeat_len.push(len); @@ -250,7 +250,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { } // FIXME #2887: think about span stuff here TTNonterminal(sp, ident) => { - r.stack.mut_last().unwrap().idx += 1; + r.stack.last_mut().unwrap().idx += 1; match *lookup_cur_matched(r, ident) { /* sidestep the interpolation tricks for ident because (a) idents can be in lots of places, so it'd be a pain diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index e63954c36806e..4806c5fa7c062 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -37,7 +37,7 @@ pub trait MoveMap { impl MoveMap for Vec { fn move_map(mut self, f: |T| -> T) -> Vec { use std::{mem, ptr}; - for p in self.mut_iter() { + for p in self.iter_mut() { unsafe { // FIXME(#5016) this shouldn't need to zero to be safe. mem::move_val_init(p, f(ptr::read_and_zero(p))); @@ -351,7 +351,7 @@ pub fn noop_fold_decl(d: P, fld: &mut T) -> SmallVector node: DeclLocal(fld.fold_local(l)), span: fld.new_span(span) })), - DeclItem(it) => fld.fold_item(it).move_iter().map(|i| P(Spanned { + DeclItem(it) => fld.fold_item(it).into_iter().map(|i| P(Spanned { node: DeclItem(i), span: fld.new_span(span) })).collect() @@ -819,7 +819,7 @@ pub fn noop_fold_block(b: P, folder: &mut T) -> P { b.map(|Block {id, view_items, stmts, expr, rules, span}| Block { id: folder.new_id(id), view_items: view_items.move_map(|x| folder.fold_view_item(x)), - stmts: stmts.move_iter().flat_map(|s| folder.fold_stmt(s).move_iter()).collect(), + stmts: stmts.into_iter().flat_map(|s| folder.fold_stmt(s).into_iter()).collect(), expr: expr.map(|x| folder.fold_expr(x)), rules: rules, span: folder.new_span(span), @@ -860,17 +860,17 @@ pub fn noop_fold_item_underscore(i: Item_, folder: &mut T) -> Item_ { ItemImpl(folder.fold_generics(generics), ifce.map(|p| folder.fold_trait_ref(p)), folder.fold_ty(ty), - impl_items.move_iter().flat_map(|impl_item| match impl_item { + impl_items.into_iter().flat_map(|impl_item| match impl_item { MethodImplItem(x) => { - folder.fold_method(x).move_iter().map(|x| MethodImplItem(x)) + folder.fold_method(x).into_iter().map(|x| MethodImplItem(x)) } }).collect()) } ItemTrait(generics, unbound, bounds, methods) => { let bounds = folder.fold_bounds(bounds); - let methods = methods.move_iter().flat_map(|method| match method { + let methods = methods.into_iter().flat_map(|method| match method { RequiredMethod(m) => { - SmallVector::one(RequiredMethod(folder.fold_type_method(m))).move_iter() + SmallVector::one(RequiredMethod(folder.fold_type_method(m))).into_iter() } ProvidedMethod(method) => { // the awkward collect/iter idiom here is because @@ -878,9 +878,9 @@ pub fn noop_fold_item_underscore(i: Item_, folder: &mut T) -> Item_ { // they're not actually the same type, so the method arms // don't unify. let methods: SmallVector = - folder.fold_method(method).move_iter() + folder.fold_method(method).into_iter() .map(|m| ProvidedMethod(m)).collect(); - methods.move_iter() + methods.into_iter() } }).collect(); ItemTrait(folder.fold_generics(generics), @@ -912,7 +912,7 @@ pub fn noop_fold_mod(Mod {inner, view_items, items}: Mod, folder: &mu Mod { inner: folder.new_span(inner), view_items: view_items.move_map(|x| folder.fold_view_item(x)), - items: items.move_iter().flat_map(|x| folder.fold_item(x).move_iter()).collect(), + items: items.into_iter().flat_map(|x| folder.fold_item(x).into_iter()).collect(), } } @@ -1194,7 +1194,7 @@ pub fn noop_fold_stmt(Spanned {node, span}: Stmt, folder: &mut T) match node { StmtDecl(d, id) => { let id = folder.new_id(id); - folder.fold_decl(d).move_iter().map(|d| P(Spanned { + folder.fold_decl(d).into_iter().map(|d| P(Spanned { node: StmtDecl(d, id), span: span })).collect() diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index 33482ec0eb359..798a54c1062d4 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -49,7 +49,7 @@ impl Drop for OwnedSlice { impl OwnedSlice { pub fn empty() -> OwnedSlice { - OwnedSlice { data: ptr::mut_null(), len: 0 } + OwnedSlice { data: ptr::null_mut(), len: 0 } } #[inline(never)] @@ -106,7 +106,7 @@ impl OwnedSlice { } pub fn move_iter(self) -> vec::MoveItems { - self.into_vec().move_iter() + self.into_vec().into_iter() } pub fn map(&self, f: |&T| -> U) -> OwnedSlice { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 844848416139b..a6a2ecb199a3a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1295,7 +1295,7 @@ impl<'a> Parser<'a> { let (inner_attrs, body) = p.parse_inner_attrs_and_block(); let mut attrs = attrs; - attrs.extend(inner_attrs.move_iter()); + attrs.extend(inner_attrs.into_iter()); ProvidedMethod(P(ast::Method { attrs: attrs, id: ast::DUMMY_NODE_ID, @@ -1404,7 +1404,7 @@ impl<'a> Parser<'a> { if ts.len() == 1 && !one_tuple { self.expect(&token::RPAREN); - TyParen(ts.move_iter().nth(0).unwrap()) + TyParen(ts.into_iter().nth(0).unwrap()) } else { let t = TyTup(ts); self.expect(&token::RPAREN); @@ -2011,7 +2011,7 @@ impl<'a> Parser<'a> { self.commit_expr_expecting(&**es.last().unwrap(), token::RPAREN); return if es.len() == 1 && !trailing_comma { - self.mk_expr(lo, hi, ExprParen(es.move_iter().nth(0).unwrap())) + self.mk_expr(lo, hi, ExprParen(es.into_iter().nth(0).unwrap())) } else { self.mk_expr(lo, hi, ExprTup(es)) } @@ -3500,7 +3500,7 @@ impl<'a> Parser<'a> { } = self.parse_items_and_view_items(first_item_attrs, false, false); - for item in items.move_iter() { + for item in items.into_iter() { let span = item.span; let decl = P(spanned(span.lo, span.hi, DeclItem(item))); stmts.push(P(spanned(span.lo, span.hi, StmtDecl(decl, ast::DUMMY_NODE_ID)))); @@ -3898,7 +3898,7 @@ impl<'a> Parser<'a> { "variadic function must be declared with at least one named argument"); } - let args = args.move_iter().map(|x| x.unwrap()).collect(); + let args = args.into_iter().map(|x| x.unwrap()).collect(); (args, variadic) } @@ -4958,7 +4958,7 @@ impl<'a> Parser<'a> { seq_sep_trailing_allowed(token::COMMA), |p| p.parse_ty(true) ); - for ty in arg_tys.move_iter() { + for ty in arg_tys.into_iter() { args.push(ast::VariantArg { ty: ty, id: ast::DUMMY_NODE_ID, @@ -5057,7 +5057,7 @@ impl<'a> Parser<'a> { self.bump(); let mut attrs = attrs; mem::swap(&mut item.attrs, &mut attrs); - item.attrs.extend(attrs.move_iter()); + item.attrs.extend(attrs.into_iter()); return IoviItem(P(item)); } None => {} @@ -5408,7 +5408,7 @@ impl<'a> Parser<'a> { let path = ast::Path { span: span, global: false, - segments: path.move_iter().map(|identifier| { + segments: path.into_iter().map(|identifier| { ast::PathSegment { identifier: identifier, lifetimes: Vec::new(), @@ -5443,7 +5443,7 @@ impl<'a> Parser<'a> { let path = ast::Path { span: mk_sp(lo, self.span.hi), global: false, - segments: path.move_iter().map(|identifier| { + segments: path.into_iter().map(|identifier| { ast::PathSegment { identifier: identifier, lifetimes: Vec::new(), @@ -5461,7 +5461,7 @@ impl<'a> Parser<'a> { let path = ast::Path { span: mk_sp(lo, self.span.hi), global: false, - segments: path.move_iter().map(|identifier| { + segments: path.into_iter().map(|identifier| { ast::PathSegment { identifier: identifier, lifetimes: Vec::new(), @@ -5483,7 +5483,7 @@ impl<'a> Parser<'a> { let path = ast::Path { span: mk_sp(lo, self.span.hi), global: false, - segments: path.move_iter().map(|identifier| { + segments: path.into_iter().map(|identifier| { ast::PathSegment { identifier: identifier, lifetimes: Vec::new(), diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 47aef987a63d0..a3f081e7be4de 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -90,7 +90,7 @@ impl SmallVector { } pub fn push_all(&mut self, other: SmallVector) { - for v in other.move_iter() { + for v in other.into_iter() { self.push(v); } } @@ -108,7 +108,7 @@ impl SmallVector { One(v) => v, Many(v) => { if v.len() == 1 { - v.move_iter().next().unwrap() + v.into_iter().next().unwrap() } else { fail!(err) } @@ -117,11 +117,17 @@ impl SmallVector { } } + /// Deprecated: use `into_iter`. + #[deprecated = "use into_iter"] pub fn move_iter(self) -> MoveItems { + self.into_iter() + } + + pub fn into_iter(self) -> MoveItems { let repr = match self.repr { Zero => ZeroIterator, One(v) => OneIterator(v), - Many(vs) => ManyIterator(vs.move_iter()) + Many(vs) => ManyIterator(vs.into_iter()) }; MoveItems { repr: repr } } @@ -202,7 +208,7 @@ mod test { #[test] fn test_from_iter() { - let v: SmallVector = (vec!(1i, 2, 3)).move_iter().collect(); + let v: SmallVector = (vec!(1i, 2, 3)).into_iter().collect(); assert_eq!(3, v.len()); assert_eq!(&1, v.get(0)); assert_eq!(&2, v.get(1)); @@ -212,14 +218,14 @@ mod test { #[test] fn test_move_iter() { let v = SmallVector::zero(); - let v: Vec = v.move_iter().collect(); + let v: Vec = v.into_iter().collect(); assert_eq!(Vec::new(), v); let v = SmallVector::one(1i); - assert_eq!(vec!(1i), v.move_iter().collect()); + assert_eq!(vec!(1i), v.into_iter().collect()); let v = SmallVector::many(vec!(1i, 2i, 3i)); - assert_eq!(vec!(1i, 2i, 3i), v.move_iter().collect()); + assert_eq!(vec!(1i, 2i, 3i), v.into_iter().collect()); } #[test] diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index fdbe6eeadfd8a..e6fc64cbd3b0c 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -102,7 +102,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), ]; - for (dst, src) in mparams.mut_iter().zip(params.iter()) { + for (dst, src) in mparams.iter_mut().zip(params.iter()) { *dst = (*src).clone(); } @@ -501,7 +501,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result ,String> { return Err("non-number on stack with %s".to_string()) } }; - let mut s: Vec = s.move_iter().collect(); + let mut s: Vec = s.into_iter().collect(); if flags.precision > s.len() { let mut s_ = Vec::with_capacity(flags.precision); let n = flags.precision - s.len(); @@ -532,7 +532,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result ,String> { .to_ascii() .to_upper() .into_bytes() - .move_iter() + .into_iter() .collect(); if flags.alternate { let s_ = replace(&mut s, vec!(b'0', b'X')); diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index ea5c8424ea302..758496fa2c244 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -949,7 +949,7 @@ fn run_tests(opts: &TestOpts, // All benchmarks run at the end, in serial. // (this includes metric fns) - for b in filtered_benchs_and_metrics.move_iter() { + for b in filtered_benchs_and_metrics.into_iter() { try!(callback(TeWait(b.desc.clone(), b.testfn.padding()))); run_test(opts, !opts.run_benchmarks, b, tx.clone()); let (test, result, stdout) = rx.recv(); @@ -981,7 +981,7 @@ pub fn filter_tests(opts: &TestOpts, tests: Vec) -> Vec filtered, Some(ref re) => { - filtered.move_iter() + filtered.into_iter() .filter(|test| re.is_match(test.desc.name.as_slice())).collect() } }; @@ -1001,7 +1001,7 @@ pub fn filter_tests(opts: &TestOpts, tests: Vec) -> Vec) -> Vec filtered, Some((a,b)) => { - filtered.move_iter().enumerate() + filtered.into_iter().enumerate() // note: using a - 1 so that the valid shards, for example, are // 1.2 and 2.2 instead of 0.2 and 1.2 .filter(|&(i,_)| i % b == (a - 1)) @@ -1054,7 +1054,7 @@ pub fn run_test(opts: &TestOpts, } let result_future = task.try_future(testfn); - let stdout = reader.read_to_end().unwrap().move_iter().collect(); + let stdout = reader.read_to_end().unwrap().into_iter().collect(); let task_result = result_future.unwrap(); let test_result = calc_result(&desc, task_result.is_ok()); monitor_ch.send((desc.clone(), test_result, stdout)); @@ -1328,7 +1328,7 @@ impl Bencher { loop { let loop_start = precise_time_ns(); - for p in samples.mut_iter() { + for p in samples.iter_mut() { self.bench_n(n, |x| f(x)); *p = self.ns_per_iter() as f64; }; @@ -1336,7 +1336,7 @@ impl Bencher { stats::winsorize(samples, 5.0); let summ = stats::Summary::new(samples); - for p in samples.mut_iter() { + for p in samples.iter_mut() { self.bench_n(5 * n, |x| f(x)); *p = self.ns_per_iter() as f64; }; diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs index 9af28e771e1fb..7087d4c423838 100644 --- a/src/libtest/stats.rs +++ b/src/libtest/stats.rs @@ -323,7 +323,7 @@ pub fn winsorize(samples: &mut [T], pct: T) { let lo = percentile_of_sorted(tmp.as_slice(), pct); let hundred: T = FromPrimitive::from_uint(100).unwrap(); let hi = percentile_of_sorted(tmp.as_slice(), hundred-pct); - for samp in samples.mut_iter() { + for samp in samples.iter_mut() { if *samp > hi { *samp = hi } else if *samp < lo { diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index 4a63aaf850a64..abf6fc5f2558c 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -155,7 +155,7 @@ pub fn get_time() -> Timespec { unsafe fn os_get_time() -> (i64, i32) { use std::ptr; let mut tv = libc::timeval { tv_sec: 0, tv_usec: 0 }; - imp::gettimeofday(&mut tv, ptr::mut_null()); + imp::gettimeofday(&mut tv, ptr::null_mut()); (tv.tv_sec as i64, tv.tv_usec * 1000) } diff --git a/src/test/bench/core-uint-to-str.rs b/src/test/bench/core-uint-to-str.rs index f385175156609..1f527e89eb23f 100644 --- a/src/test/bench/core-uint-to-str.rs +++ b/src/test/bench/core-uint-to-str.rs @@ -18,7 +18,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "100000".to_string()) } else { - args.move_iter().collect() + args.into_iter().collect() }; let n = from_str::(args.get(1).as_slice()).unwrap(); diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 14155d54d73cc..3b39ce610a1f5 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -75,7 +75,7 @@ fn run(args: &[String]) { server(&from_parent, &to_parent); }); - for r in worker_results.move_iter() { + for r in worker_results.into_iter() { r.unwrap(); } @@ -99,7 +99,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "10000".to_string(), "4".to_string()) } else { - args.move_iter().map(|x| x.to_string()).collect() + args.into_iter().map(|x| x.to_string()).collect() }; println!("{}", args); diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 7ec2796b230a7..f103014ca8804 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -83,7 +83,7 @@ fn run(args: &[String]) { server(&from_parent, &to_parent); }); - for r in worker_results.move_iter() { + for r in worker_results.into_iter() { r.unwrap(); } @@ -107,7 +107,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "10000".to_string(), "4".to_string()) } else { - args.clone().move_iter().map(|x| x.to_string()).collect() + args.clone().into_iter().map(|x| x.to_string()).collect() }; println!("{:?}", args); diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index ebd5aa4b37bec..d1a2dcf6d5588 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -69,7 +69,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "10".to_string(), "100".to_string()) } else { - args.clone().move_iter().collect() + args.clone().into_iter().collect() }; let num_tasks = from_str::(args.get(1).as_slice()).unwrap(); @@ -97,7 +97,7 @@ fn main() { thread_ring(0, msg_per_task, num_chan, num_port); // synchronize - for f in futures.mut_iter() { + for f in futures.iter_mut() { f.get() } diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index 764d80984c304..c07656a5e4b6d 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -69,7 +69,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "10".to_string(), "100".to_string()) } else { - args.clone().move_iter().collect() + args.clone().into_iter().collect() }; let num_tasks = from_str::(args.get(1).as_slice()).unwrap(); @@ -97,7 +97,7 @@ fn main() { thread_ring(0, msg_per_task, num_chan, num_port); // synchronize - for f in futures.mut_iter() { + for f in futures.iter_mut() { let _ = f.get(); } diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index bdca03490369a..19ccf1b6caf72 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -43,12 +43,12 @@ impl Noise2DContext { let mut rng = StdRng::new().unwrap(); let mut rgradients = [Vec2 { x: 0.0, y: 0.0 }, ..256]; - for x in rgradients.mut_iter() { + for x in rgradients.iter_mut() { *x = random_gradient(&mut rng); } let mut permutations = [0i32, ..256]; - for (i, x) in permutations.mut_iter().enumerate() { + for (i, x) in permutations.iter_mut().enumerate() { *x = i as i32; } rng.shuffle(permutations); diff --git a/src/test/bench/shootout-ackermann.rs b/src/test/bench/shootout-ackermann.rs index d8eceec6321df..90d2c85785837 100644 --- a/src/test/bench/shootout-ackermann.rs +++ b/src/test/bench/shootout-ackermann.rs @@ -29,7 +29,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "8".to_string()) } else { - args.move_iter().collect() + args.into_iter().collect() }; let n = from_str::(args.get(1).as_slice()).unwrap(); println!("Ack(3,{}): {}\n", n, ack(3, n)); diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 822565ec1279b..a0c69b3736d5b 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -108,7 +108,7 @@ fn main() { }) }).collect::>>(); - for message in messages.mut_iter() { + for message in messages.iter_mut() { println!("{}", *message.get_ref()); } diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index f0798a9e7e82f..5e812e500d6e8 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -43,14 +43,14 @@ use std::sync::Future; fn rotate(x: &mut [i32]) { let mut prev = x[0]; - for place in x.mut_iter().rev() { + for place in x.iter_mut().rev() { prev = mem::replace(place, prev) } } fn next_permutation(perm: &mut [i32], count: &mut [i32]) { for i in range(1, perm.len()) { - rotate(perm.mut_slice_to(i + 1)); + rotate(perm.slice_to_mut(i + 1)); let count_i = &mut count[i]; if *count_i >= i as i32 { *count_i = 0; @@ -91,7 +91,7 @@ impl Perm { fn get(&mut self, mut idx: i32) -> P { let mut pp = [0u8, .. 16]; self.permcount = idx as u32; - for (i, place) in self.perm.p.mut_iter().enumerate() { + for (i, place) in self.perm.p.iter_mut().enumerate() { *place = i as i32 + 1; } @@ -99,7 +99,7 @@ impl Perm { let d = idx / self.fact[i] as i32; self.cnt[i] = d; idx %= self.fact[i] as i32; - for (place, val) in pp.mut_iter().zip(self.perm.p.slice_to(i + 1).iter()) { + for (place, val) in pp.iter_mut().zip(self.perm.p.slice_to(i + 1).iter()) { *place = (*val) as u8 } @@ -125,7 +125,7 @@ impl Perm { fn reverse(tperm: &mut [i32], mut k: uint) { - tperm.mut_slice_to(k).reverse() + tperm.slice_to_mut(k).reverse() } fn work(mut perm: Perm, n: uint, max: uint) -> (i32, i32) { @@ -169,7 +169,7 @@ fn fannkuch(n: i32) -> (i32, i32) { let mut checksum = 0; let mut maxflips = 0; - for fut in futures.mut_iter() { + for fut in futures.iter_mut() { let (cs, mf) = fut.get(); checksum += cs; maxflips = cmp::max(maxflips, mf); diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 03f986863240c..8e10cb089fa30 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -94,7 +94,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> { copy_memory(buf.as_mut_slice(), alu); let buf_len = buf.len(); - copy_memory(buf.mut_slice(alu_len, buf_len), + copy_memory(buf.slice_mut(alu_len, buf_len), alu.slice_to(LINE_LEN)); let mut pos = 0; @@ -117,7 +117,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> { fn make_lookup(a: &[AminoAcid]) -> [AminoAcid, ..LOOKUP_SIZE] { let mut lookup = [ NULL_AMINO_ACID, ..LOOKUP_SIZE ]; let mut j = 0; - for (i, slot) in lookup.mut_iter().enumerate() { + for (i, slot) in lookup.iter_mut().enumerate() { while a[j].p < (i as f32) { j += 1; } diff --git a/src/test/bench/shootout-fibo.rs b/src/test/bench/shootout-fibo.rs index 83db926ad6cfa..1f42cc6e00c5d 100644 --- a/src/test/bench/shootout-fibo.rs +++ b/src/test/bench/shootout-fibo.rs @@ -25,7 +25,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "30".to_string()) } else { - args.move_iter().collect() + args.into_iter().collect() }; let n = from_str::(args.get(1).as_slice()).unwrap(); println!("{}\n", fib(n)); diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 143175e558b6d..f4d1cee5fb4ca 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -157,7 +157,7 @@ fn main() { let sizes = vec!(1u,2,3,4,6,12,18); let mut streams = Vec::from_fn(sizes.len(), |_| Some(channel::())); let mut from_child = Vec::new(); - let to_child = sizes.iter().zip(streams.mut_iter()).map(|(sz, stream_ref)| { + let to_child = sizes.iter().zip(streams.iter_mut()).map(|(sz, stream_ref)| { let sz = *sz; let stream = replace(stream_ref, None); let (to_parent_, from_child_) = stream.unwrap(); diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 59cbc6bc0043e..cecc95354afef 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -283,7 +283,7 @@ fn get_sequence(r: &mut R, key: &str) -> Vec { { res.push_all(l.as_slice().trim().as_bytes()); } - for b in res.mut_iter() { + for b in res.iter_mut() { *b = b.to_ascii().to_upper().to_byte(); } res @@ -307,10 +307,10 @@ fn main() { Future::spawn(proc() generate_frequencies(input.as_slice(), occ.len())) }).collect(); - for (i, freq) in nb_freqs.move_iter() { + for (i, freq) in nb_freqs.into_iter() { print_frequencies(&freq.unwrap(), i); } - for (&occ, freq) in OCCURRENCES.iter().zip(occ_freqs.move_iter()) { + for (&occ, freq) in OCCURRENCES.iter().zip(occ_freqs.into_iter()) { print_occurrences(&mut freq.unwrap(), occ); } } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index b0e23983192f2..28db9ed14a77b 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -107,7 +107,7 @@ fn mandelbrot(w: uint, mut out: W) -> io::IoResult<()> { }) }); - for res in precalc_futures.move_iter() { + for res in precalc_futures.into_iter() { let (rs, is) = res.unwrap(); precalc_r.push_all_move(rs); precalc_i.push_all_move(is); @@ -135,7 +135,7 @@ fn mandelbrot(w: uint, mut out: W) -> io::IoResult<()> { }); try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h)); - for res in data.move_iter() { + for res in data.into_iter() { try!(out.write(res.unwrap().as_slice())); } out.flush() diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index c46c44abcd4c8..9542a9a55ee5a 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -114,9 +114,9 @@ fn transform(piece: Vec<(int, int)> , all: bool) -> Vec> { }).collect(); // translating to (0, 0) as minimum coordinates. - for cur_piece in res.mut_iter() { + for cur_piece in res.iter_mut() { let (dy, dx) = *cur_piece.iter().min_by(|e| *e).unwrap(); - for &(ref mut y, ref mut x) in cur_piece.mut_iter() { + for &(ref mut y, ref mut x) in cur_piece.iter_mut() { *y -= dy; *x -= dx; } } @@ -163,7 +163,7 @@ fn make_masks() -> Vec > > { // transformation must be taken except for one piece (piece 3 // here). let transforms: Vec>> = - pieces.move_iter().enumerate() + pieces.into_iter().enumerate() .map(|(id, p)| transform(p, id != 3)) .collect(); diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 9e30a51247719..6a39d2fdbb1a3 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -106,7 +106,7 @@ fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: int) { Some(bi) => bi, None => break }; - for bj in b_slice.mut_iter() { + for bj in b_slice.iter_mut() { let dx = bi.x - bj.x; let dy = bi.y - bj.y; let dz = bi.z - bj.z; diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 0e0b0b518d587..516bd99ab550a 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -82,7 +82,7 @@ fn stress(num_tasks: int) { stress_task(i); })); } - for r in results.move_iter() { + for r in results.into_iter() { r.unwrap(); } } @@ -94,7 +94,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "8".to_string()) } else { - args.move_iter().map(|x| x.to_string()).collect() + args.into_iter().map(|x| x.to_string()).collect() }; let opts = parse_opts(args.clone()); diff --git a/src/test/bench/shootout-regex-dna.rs b/src/test/bench/shootout-regex-dna.rs index 433d62c7e964b..0adb80c2689ba 100644 --- a/src/test/bench/shootout-regex-dna.rs +++ b/src/test/bench/shootout-regex-dna.rs @@ -87,7 +87,7 @@ fn main() { (regex!("Y"), "(c|t)"), ]; let mut seq = seq; - for (re, replacement) in substs.move_iter() { + for (re, replacement) in substs.into_iter() { seq = re.replace_all(seq.as_slice(), NoExpand(replacement)); } seq.len() @@ -105,7 +105,7 @@ fn main() { regex!("agggtaa[cgt]|[acg]ttaccct"), ]; let (mut variant_strs, mut counts) = (vec!(), vec!()); - for variant in variants.move_iter() { + for variant in variants.into_iter() { let seq_arc_copy = seq_arc.clone(); variant_strs.push(variant.to_string()); counts.push(Future::spawn(proc() { diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index 52defe6a2767d..e522bcaf4db7b 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -54,7 +54,7 @@ fn make_complements() -> [u8, ..256] { ('H', 'D'), ('D', 'H'), ('B', 'V'), ('N', 'N'), ('\n', '\n')]; let mut complements: [u8, ..256] = [0, ..256]; - for (i, c) in complements.mut_iter().enumerate() { + for (i, c) in complements.iter_mut().enumerate() { *c = i as u8; } let lower = 'A' as u8 - 'a' as u8; @@ -74,14 +74,14 @@ fn main() { }; let mut data = data.unwrap(); - for seq in data.as_mut_slice().mut_split(|c| *c == '>' as u8) { + for seq in data.as_mut_slice().split_mut(|c| *c == '>' as u8) { // skip header and last \n let begin = match seq.iter().position(|c| *c == '\n' as u8) { None => continue, Some(c) => c }; let len = seq.len(); - let seq = seq.mut_slice(begin + 1, len - 1); + let seq = seq.slice_mut(begin + 1, len - 1); // arrange line breaks let len = seq.len(); @@ -94,9 +94,9 @@ fn main() { } // reverse complement, as - // seq.reverse(); for c in seq.mut_iter() {*c = complements[*c]} + // seq.reverse(); for c in seq.iter_mut() {*c = complements[*c]} // but faster: - let mut it = seq.mut_iter(); + let mut it = seq.iter_mut(); loop { match (it.next(), it.next_back()) { (Some(front), Some(back)) => { diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index ae05466eb9cb8..ba1bce2f834f9 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -37,7 +37,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "10000".to_string(), "50".to_string()) } else { - args.move_iter().collect() + args.into_iter().collect() }; let max = from_str::(args.get(1).as_slice()).unwrap(); let rep = from_str::(args.get(2).as_slice()).unwrap(); diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index c631e3e04f2ef..17e1ad423f9cc 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -45,7 +45,7 @@ fn main() { } else if args.len() <= 1 { vec!("".to_string(), "100".to_string()) } else { - args.clone().move_iter().collect() + args.clone().into_iter().collect() }; let (tx, rx) = channel(); diff --git a/src/test/bench/task-perf-one-million.rs b/src/test/bench/task-perf-one-million.rs index c980d531bb5eb..0f903be39223d 100644 --- a/src/test/bench/task-perf-one-million.rs +++ b/src/test/bench/task-perf-one-million.rs @@ -28,20 +28,20 @@ fn calc(children: uint, parent_wait_chan: &Sender>>) { }); let child_start_chans: Vec>> = - wait_ports.move_iter().map(|port| port.recv()).collect(); + wait_ports.into_iter().map(|port| port.recv()).collect(); let (start_port, start_chan) = stream::>(); parent_wait_chan.send(start_chan); let parent_result_chan: Sender = start_port.recv(); let child_sum_ports: Vec> = - child_start_chans.move_iter().map(|child_start_chan| { + child_start_chans.into_iter().map(|child_start_chan| { let (child_sum_port, child_sum_chan) = stream::(); child_start_chan.send(child_sum_chan); child_sum_port }).collect(); - let sum = child_sum_ports.move_iter().fold(0, |sum, sum_port| sum + sum_port.recv() ); + let sum = child_sum_ports.into_iter().fold(0, |sum, sum_port| sum + sum_port.recv() ); parent_result_chan.send(sum + 1); } diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs index 8b090d6d7fb79..a871ac989f3fa 100644 --- a/src/test/bench/task-perf-spawnalot.rs +++ b/src/test/bench/task-perf-spawnalot.rs @@ -29,7 +29,7 @@ fn main() { } else if args.len() <= 1u { vec!("".to_string(), "10".to_string()) } else { - args.move_iter().collect() + args.into_iter().collect() }; let n = from_str::(args.get(1).as_slice()).unwrap(); let mut i = 0u; diff --git a/src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs b/src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs index 7962617916346..a6723a04611af 100644 --- a/src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs +++ b/src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs @@ -11,6 +11,6 @@ use std::rc::Rc; pub fn main() { - let _x = Rc::new(vec!(1i, 2)).move_iter(); + let _x = Rc::new(vec!(1i, 2)).into_iter(); //~^ ERROR cannot move out of dereference of `&`-pointer } diff --git a/src/test/compile-fail/moves-based-on-type-access-to-field.rs b/src/test/compile-fail/moves-based-on-type-access-to-field.rs index f09e80974bd42..6214466cd49e7 100644 --- a/src/test/compile-fail/moves-based-on-type-access-to-field.rs +++ b/src/test/compile-fail/moves-based-on-type-access-to-field.rs @@ -19,7 +19,7 @@ fn touch(_a: &A) {} fn f20() { let x = vec!("hi".to_string()); - consume(x.move_iter().next().unwrap()); + consume(x.into_iter().next().unwrap()); touch(x.get(0)); //~ ERROR use of moved value: `x` } diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs index a6f7fb2433188..330fd9f1ff0a2 100644 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ b/src/test/compile-fail/moves-based-on-type-exprs.rs @@ -83,13 +83,13 @@ fn f80() { fn f100() { let x = vec!("hi".to_string()); - let _y = x.move_iter().next().unwrap(); + let _y = x.into_iter().next().unwrap(); touch(&x); //~ ERROR use of moved value: `x` } fn f110() { let x = vec!("hi".to_string()); - let _y = [x.move_iter().next().unwrap(), ..1]; + let _y = [x.into_iter().next().unwrap(), ..1]; touch(&x); //~ ERROR use of moved value: `x` } diff --git a/src/test/compile-fail/std-uncopyable-atomics.rs b/src/test/compile-fail/std-uncopyable-atomics.rs index fa2cf6bda33d7..0e8c2f38afbed 100644 --- a/src/test/compile-fail/std-uncopyable-atomics.rs +++ b/src/test/compile-fail/std-uncopyable-atomics.rs @@ -22,7 +22,7 @@ fn main() { let x = *&x; //~ ERROR: cannot move out of dereference let x = INIT_ATOMIC_UINT; //~ ERROR cannot move out of static item let x = *&x; //~ ERROR: cannot move out of dereference - let x: AtomicPtr = AtomicPtr::new(ptr::mut_null()); + let x: AtomicPtr = AtomicPtr::new(ptr::null_mut()); let x = *&x; //~ ERROR: cannot move out of dereference let x: AtomicOption = AtomicOption::empty(); let x = *&x; //~ ERROR: cannot move out of dereference diff --git a/src/test/compile-fail/vec-mut-iter-borrow.rs b/src/test/compile-fail/vec-mut-iter-borrow.rs index 9060ed7495ee5..c03956c42cb30 100644 --- a/src/test/compile-fail/vec-mut-iter-borrow.rs +++ b/src/test/compile-fail/vec-mut-iter-borrow.rs @@ -11,7 +11,7 @@ fn main() { let mut xs: Vec = vec!(); - for x in xs.mut_iter() { + for x in xs.iter_mut() { xs.push(1i) //~ ERROR cannot borrow `xs` } } diff --git a/src/test/debuginfo/type-names.rs b/src/test/debuginfo/type-names.rs index ac5fe83027527..2ea9ff7a2dd72 100644 --- a/src/test/debuginfo/type-names.rs +++ b/src/test/debuginfo/type-names.rs @@ -269,9 +269,9 @@ fn main() { let mut_ref2 = (&mut mut_generic_struct, 0i32); // Raw Pointers - let mut_ptr1: (*mut Struct1, int) = (ptr::mut_null(), 0); - let mut_ptr2: (*mut int, int) = (ptr::mut_null(), 0); - let mut_ptr3: (*mut Mod1::Mod2::Enum3, int) = (ptr::mut_null(), 0); + let mut_ptr1: (*mut Struct1, int) = (ptr::null_mut(), 0); + let mut_ptr2: (*mut int, int) = (ptr::null_mut(), 0); + let mut_ptr3: (*mut Mod1::Mod2::Enum3, int) = (ptr::null_mut(), 0); let const_ptr1: (*const Struct1, int) = (ptr::null(), 0); let const_ptr2: (*const int, int) = (ptr::null(), 0); diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 5d1a502490140..f5766ae1e53c2 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -9,7 +9,7 @@ // except according to those terms. -fn f(x: Vec) -> T { return x.move_iter().next().unwrap(); } +fn f(x: Vec) -> T { return x.into_iter().next().unwrap(); } fn g(act: |Vec | -> int) -> int { return act(vec!(1, 2, 3)); } diff --git a/src/test/run-pass/const-vec-of-fns.rs b/src/test/run-pass/const-vec-of-fns.rs index 202354b1326dd..86cac14b4439d 100644 --- a/src/test/run-pass/const-vec-of-fns.rs +++ b/src/test/run-pass/const-vec-of-fns.rs @@ -23,7 +23,7 @@ static mut closures: &'static mut [S<'static>] = &mut [S(f), S(f)]; pub fn main() { unsafe { for &bare_fn in bare_fns.iter() { bare_fn() } - for closure in closures.mut_iter() { + for closure in closures.iter_mut() { let S(ref mut closure) = *closure; (*closure)() } diff --git a/src/test/run-pass/dst-raw.rs b/src/test/run-pass/dst-raw.rs index ef4a9edaa743e..19af9fd7ea7b4 100644 --- a/src/test/run-pass/dst-raw.rs +++ b/src/test/run-pass/dst-raw.rs @@ -109,4 +109,4 @@ pub fn main() { let len = (&*c).f.len(); assert!(len == 3); } -} \ No newline at end of file +} diff --git a/src/test/run-pass/issue-16151.rs b/src/test/run-pass/issue-16151.rs index 9cc571c7819cd..5401d6a6fdced 100644 --- a/src/test/run-pass/issue-16151.rs +++ b/src/test/run-pass/issue-16151.rs @@ -26,7 +26,7 @@ fn main() { { let mut fragments = vec![Fragment, Fragment, Fragment]; let _new_fragments: Vec = mem::replace(&mut fragments, vec![]) - .move_iter() + .into_iter() .skip_while(|_fragment| { true }).collect(); diff --git a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs index ffab06e2203e8..ef0bc75c32661 100644 --- a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs +++ b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs @@ -16,7 +16,7 @@ fn test1() { fn test2() { let mut ints = [0i, ..32]; - for i in ints.mut_iter() { *i += 22; } + for i in ints.iter_mut() { *i += 22; } for i in ints.iter() { assert!(*i == 22); } } diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index 4d15e4fe21593..437f35d182bb3 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -19,7 +19,7 @@ fn myvec_deref(mv: myvec) -> Vec { fn myvec_elt(mv: myvec) -> X { let myvec(v) = mv; - return v.move_iter().next().unwrap(); + return v.into_iter().next().unwrap(); } pub fn main() { diff --git a/src/test/run-pass/realloc-16687.rs b/src/test/run-pass/realloc-16687.rs index 2e8c23fe5ba2c..fa38d647c7c94 100644 --- a/src/test/run-pass/realloc-16687.rs +++ b/src/test/run-pass/realloc-16687.rs @@ -26,7 +26,7 @@ fn main() { unsafe fn test_triangle() -> bool { static COUNT : uint = 16; - let mut ascend = Vec::from_elem(COUNT, ptr::mut_null()); + let mut ascend = Vec::from_elem(COUNT, ptr::null_mut()); let ascend = ascend.as_mut_slice(); static ALIGN : uint = 1; diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index e17f140994421..5de34dc2df5df 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -141,7 +141,7 @@ pub fn main() { println!("type: {}", (*s).clone()); } - let vec_types: Vec = v.types.clone().move_iter().collect(); + let vec_types: Vec = v.types.clone().into_iter().collect(); assert_eq!(vec_types, vec!("bool".to_string(), "int".to_string(), "i8".to_string(), "i16".to_string())); } diff --git a/src/test/run-pass/send_str_treemap.rs b/src/test/run-pass/send_str_treemap.rs index e51c94428dae3..c6b872efa030c 100644 --- a/src/test/run-pass/send_str_treemap.rs +++ b/src/test/run-pass/send_str_treemap.rs @@ -61,7 +61,7 @@ pub fn main() { assert_eq!(map.find(&Owned("def".to_string())), Some(&d)); assert!(map.pop(&Slice("foo")).is_some()); - assert_eq!(map.move_iter().map(|(k, v)| format!("{}{}", k, v)) + assert_eq!(map.into_iter().map(|(k, v)| format!("{}{}", k, v)) .collect::>() .concat(), "abc50bcd51cde52def53".to_string()); diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index afeb9125fe64a..eb0449efa6a28 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -62,7 +62,7 @@ fn test00() { } // Join spawned tasks... - for r in results.mut_iter() { r.get_ref(); } + for r in results.iter_mut() { r.get_ref(); } println!("Completed: Final number is: "); println!("{:?}", sum); diff --git a/src/test/run-pass/vec-dst.rs b/src/test/run-pass/vec-dst.rs index 809dde38eb498..40c77850adc5a 100644 --- a/src/test/run-pass/vec-dst.rs +++ b/src/test/run-pass/vec-dst.rs @@ -78,11 +78,11 @@ fn reflect() { fn sub_expr() { // Test for a &[T] => &&[T] coercion in sub-expression position // (surpisingly, this can cause errors which are not caused by either of: - // `let x = vec.mut_slice(0, 2);` - // `foo(vec.mut_slice(0, 2));` ). + // `let x = vec.slice_mut(0, 2);` + // `foo(vec.slice_mut(0, 2));` ). let mut vec: Vec = vec!(1, 2, 3, 4); let b: &mut [int] = [1, 2]; - assert!(vec.mut_slice(0, 2) == b); + assert!(vec.slice_mut(0, 2) == b); } fn index() {