Skip to content

Commit

Permalink
Fallout from stabilization
Browse files Browse the repository at this point in the history
  • Loading branch information
aturon committed Dec 31, 2014
1 parent 6e1879e commit 6abfac0
Show file tree
Hide file tree
Showing 78 changed files with 410 additions and 425 deletions.
6 changes: 3 additions & 3 deletions src/compiletest/runtest.rs
Expand Up @@ -32,6 +32,7 @@ use std::io::process;
use std::io::timer;
use std::io;
use std::os;
use std::iter::repeat;
use std::str;
use std::string::String;
use std::thread::Thread;
Expand Down Expand Up @@ -976,8 +977,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
proc_res: &ProcRes) {

// true if we found the error in question
let mut found_flags = Vec::from_elem(
expected_errors.len(), false);
let mut found_flags: Vec<_> = repeat(false).take(expected_errors.len()).collect();

if proc_res.status.success() {
fatal("process did not return an error status");
Expand Down Expand Up @@ -1337,7 +1337,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
// Add the arguments in the run_flags directive
args.extend(split_maybe_args(&props.run_flags).into_iter());

let prog = args.remove(0).unwrap();
let prog = args.remove(0);
return ProcArgs {
prog: prog,
args: args,
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/arc.rs
Expand Up @@ -95,7 +95,7 @@ use heap::deallocate;
/// use std::thread::Thread;
///
/// fn main() {
/// let numbers = Vec::from_fn(100, |i| i as f32);
/// let numbers: Vec<_> = range(0, 100u32).map(|i| i as f32).collect();
/// let shared_numbers = Arc::new(numbers);
///
/// for _ in range(0u, 10) {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/binary_heap.rs
Expand Up @@ -66,7 +66,7 @@
//! // for a simpler implementation.
//! fn shortest_path(adj_list: &Vec<Vec<Edge>>, start: uint, goal: uint) -> uint {
//! // dist[node] = current shortest distance from `start` to `node`
//! let mut dist = Vec::from_elem(adj_list.len(), uint::MAX);
//! let mut dist: Vec<_> = range(0, adj_list.len()).map(|_| uint::MAX).collect();
//!
//! let mut heap = BinaryHeap::new();
//!
Expand Down
10 changes: 5 additions & 5 deletions src/libcollections/bit.rs
Expand Up @@ -85,7 +85,7 @@ use core::prelude::*;
use core::cmp;
use core::default::Default;
use core::fmt;
use core::iter::{Cloned, Chain, Enumerate, Repeat, Skip, Take};
use core::iter::{Cloned, Chain, Enumerate, Repeat, Skip, Take, repeat};
use core::iter;
use core::num::Int;
use core::slice::{Iter, IterMut};
Expand Down Expand Up @@ -267,7 +267,7 @@ impl Bitv {
pub fn from_elem(nbits: uint, bit: bool) -> Bitv {
let nblocks = blocks_for_bits(nbits);
let mut bitv = Bitv {
storage: Vec::from_elem(nblocks, if bit { !0u32 } else { 0u32 }),
storage: repeat(if bit { !0u32 } else { 0u32 }).take(nblocks).collect(),
nbits: nbits
};
bitv.fix_last_block();
Expand Down Expand Up @@ -651,7 +651,7 @@ impl Bitv {

let len = self.nbits/8 +
if self.nbits % 8 == 0 { 0 } else { 1 };
Vec::from_fn(len, |i|
range(0, len).map(|i|
bit(self, i, 0) |
bit(self, i, 1) |
bit(self, i, 2) |
Expand All @@ -660,7 +660,7 @@ impl Bitv {
bit(self, i, 5) |
bit(self, i, 6) |
bit(self, i, 7)
)
).collect()
}

/// Deprecated: Use `iter().collect()`.
Expand Down Expand Up @@ -834,7 +834,7 @@ impl Bitv {
// Allocate new words, if needed
if new_nblocks > self.storage.len() {
let to_add = new_nblocks - self.storage.len();
self.storage.grow(to_add, full_value);
self.storage.extend(repeat(full_value).take(to_add));
}

// Adjust internal bit count
Expand Down
66 changes: 33 additions & 33 deletions src/libcollections/btree/node.rs
Expand Up @@ -554,10 +554,10 @@ impl <K, V> Node<K, V> {
let node = mem::replace(left_and_out, unsafe { Node::new_internal(capacity_from_b(b)) });
left_and_out._len = 1;
unsafe {
ptr::write(left_and_out.keys_mut().unsafe_mut(0), key);
ptr::write(left_and_out.vals_mut().unsafe_mut(0), value);
ptr::write(left_and_out.edges_mut().unsafe_mut(0), node);
ptr::write(left_and_out.edges_mut().unsafe_mut(1), right);
ptr::write(left_and_out.keys_mut().get_unchecked_mut(0), key);
ptr::write(left_and_out.vals_mut().get_unchecked_mut(0), value);
ptr::write(left_and_out.edges_mut().get_unchecked_mut(0), node);
ptr::write(left_and_out.edges_mut().get_unchecked_mut(1), right);
}
}

Expand Down Expand Up @@ -636,7 +636,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, handle::Edge, handle::Internal> {
/// making it more suitable for moving down a chain of nodes.
pub fn into_edge(self) -> &'a Node<K, V> {
unsafe {
self.node.edges().unsafe_get(self.index)
self.node.edges().get_unchecked(self.index)
}
}
}
Expand All @@ -647,7 +647,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, handle::Edge, handle::Internal
/// `edge_mut`, making it more suitable for moving down a chain of nodes.
pub fn into_edge_mut(self) -> &'a mut Node<K, V> {
unsafe {
self.node.edges_mut().unsafe_mut(self.index)
self.node.edges_mut().get_unchecked_mut(self.index)
}
}
}
Expand Down Expand Up @@ -721,7 +721,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::
/// confused with `node`, which references the parent node of what is returned here.
pub fn edge_mut(&mut self) -> &mut Node<K, V> {
unsafe {
self.node.edges_mut().unsafe_mut(self.index)
self.node.edges_mut().get_unchecked_mut(self.index)
}
}

Expand Down Expand Up @@ -829,8 +829,8 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, handle::KV, NodeType> {
let (keys, vals) = self.node.as_slices();
unsafe {
(
keys.unsafe_get(self.index),
vals.unsafe_get(self.index)
keys.get_unchecked(self.index),
vals.get_unchecked(self.index)
)
}
}
Expand All @@ -844,8 +844,8 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, handle::KV, NodeType
let (keys, vals) = self.node.as_slices_mut();
unsafe {
(
keys.unsafe_mut(self.index),
vals.unsafe_mut(self.index)
keys.get_unchecked_mut(self.index),
vals.get_unchecked_mut(self.index)
)
}
}
Expand All @@ -869,14 +869,14 @@ impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef
// /// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
// /// handle.
// pub fn key(&'a self) -> &'a K {
// unsafe { self.node.keys().unsafe_get(self.index) }
// unsafe { self.node.keys().get_unchecked(self.index) }
// }
//
// /// Returns a reference to the value pointed-to by this handle. This doesn't return a
// /// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
// /// handle.
// pub fn val(&'a self) -> &'a V {
// unsafe { self.node.vals().unsafe_get(self.index) }
// unsafe { self.node.vals().get_unchecked(self.index) }
// }
}

Expand All @@ -886,14 +886,14 @@ impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<Node
/// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
/// handle.
pub fn key_mut(&'a mut self) -> &'a mut K {
unsafe { self.node.keys_mut().unsafe_mut(self.index) }
unsafe { self.node.keys_mut().get_unchecked_mut(self.index) }
}

/// Returns a mutable reference to the value pointed-to by this handle. This doesn't return a
/// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
/// handle.
pub fn val_mut(&'a mut self) -> &'a mut V {
unsafe { self.node.vals_mut().unsafe_mut(self.index) }
unsafe { self.node.vals_mut().get_unchecked_mut(self.index) }
}
}

Expand Down Expand Up @@ -1077,7 +1077,7 @@ impl<K, V> Node<K, V> {
debug_assert!(!self.is_leaf());

unsafe {
let ret = ptr::read(self.edges().unsafe_get(0));
let ret = ptr::read(self.edges().get_unchecked(0));
self.destroy();
ptr::write(self, ret);
}
Expand All @@ -1091,8 +1091,8 @@ impl<K, V> Node<K, V> {
unsafe fn push_kv(&mut self, key: K, val: V) {
let len = self.len();

ptr::write(self.keys_mut().unsafe_mut(len), key);
ptr::write(self.vals_mut().unsafe_mut(len), val);
ptr::write(self.keys_mut().get_unchecked_mut(len), key);
ptr::write(self.vals_mut().get_unchecked_mut(len), val);

self._len += 1;
}
Expand All @@ -1102,7 +1102,7 @@ impl<K, V> Node<K, V> {
unsafe fn push_edge(&mut self, edge: Node<K, V>) {
let len = self.len();

ptr::write(self.edges_mut().unsafe_mut(len), edge);
ptr::write(self.edges_mut().get_unchecked_mut(len), edge);
}

// This must be followed by insert_edge on an internal node.
Expand All @@ -1119,12 +1119,12 @@ impl<K, V> Node<K, V> {
self.len() - index
);

ptr::write(self.keys_mut().unsafe_mut(index), key);
ptr::write(self.vals_mut().unsafe_mut(index), val);
ptr::write(self.keys_mut().get_unchecked_mut(index), key);
ptr::write(self.vals_mut().get_unchecked_mut(index), val);

self._len += 1;

self.vals_mut().unsafe_mut(index)
self.vals_mut().get_unchecked_mut(index)
}

// This can only be called immediately after a call to insert_kv.
Expand All @@ -1135,14 +1135,14 @@ impl<K, V> Node<K, V> {
self.edges().as_ptr().offset(index as int),
self.len() - index
);
ptr::write(self.edges_mut().unsafe_mut(index), edge);
ptr::write(self.edges_mut().get_unchecked_mut(index), edge);
}

// This must be followed by pop_edge on an internal node.
#[inline]
unsafe fn pop_kv(&mut self) -> (K, V) {
let key = ptr::read(self.keys().unsafe_get(self.len() - 1));
let val = ptr::read(self.vals().unsafe_get(self.len() - 1));
let key = ptr::read(self.keys().get_unchecked(self.len() - 1));
let val = ptr::read(self.vals().get_unchecked(self.len() - 1));

self._len -= 1;

Expand All @@ -1152,16 +1152,16 @@ impl<K, V> Node<K, V> {
// This can only be called immediately after a call to pop_kv.
#[inline]
unsafe fn pop_edge(&mut self) -> Node<K, V> {
let edge = ptr::read(self.edges().unsafe_get(self.len() + 1));
let edge = ptr::read(self.edges().get_unchecked(self.len() + 1));

edge
}

// This must be followed by remove_edge on an internal node.
#[inline]
unsafe fn remove_kv(&mut self, index: uint) -> (K, V) {
let key = ptr::read(self.keys().unsafe_get(index));
let val = ptr::read(self.vals().unsafe_get(index));
let key = ptr::read(self.keys().get_unchecked(index));
let val = ptr::read(self.vals().get_unchecked(index));

ptr::copy_memory(
self.keys_mut().as_mut_ptr().offset(index as int),
Expand All @@ -1182,7 +1182,7 @@ impl<K, V> Node<K, V> {
// This can only be called immediately after a call to remove_kv.
#[inline]
unsafe fn remove_edge(&mut self, index: uint) -> Node<K, V> {
let edge = ptr::read(self.edges().unsafe_get(index));
let edge = ptr::read(self.edges().get_unchecked(index));

ptr::copy_memory(
self.edges_mut().as_mut_ptr().offset(index as int),
Expand Down Expand Up @@ -1229,8 +1229,8 @@ impl<K, V> Node<K, V> {
);
}

let key = ptr::read(self.keys().unsafe_get(right_offset - 1));
let val = ptr::read(self.vals().unsafe_get(right_offset - 1));
let key = ptr::read(self.keys().get_unchecked(right_offset - 1));
let val = ptr::read(self.vals().get_unchecked(right_offset - 1));

self._len = right_offset - 1;

Expand All @@ -1249,8 +1249,8 @@ impl<K, V> Node<K, V> {
let old_len = self.len();
self._len += right.len() + 1;

ptr::write(self.keys_mut().unsafe_mut(old_len), key);
ptr::write(self.vals_mut().unsafe_mut(old_len), val);
ptr::write(self.keys_mut().get_unchecked_mut(old_len), key);
ptr::write(self.vals_mut().get_unchecked_mut(old_len), val);

ptr::copy_nonoverlapping_memory(
self.keys_mut().as_mut_ptr().offset(old_len as int + 1),
Expand Down
6 changes: 4 additions & 2 deletions src/libcollections/dlist.rs
Expand Up @@ -1290,8 +1290,10 @@ mod tests {
v.pop();
}
1 => {
m.pop_front();
v.remove(0);
if !v.is_empty() {
m.pop_front();
v.remove(0);
}
}
2 | 4 => {
m.push_front(-i);
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/lib.rs
Expand Up @@ -128,8 +128,8 @@ mod prelude {
pub use unicode::char::UnicodeChar;

// from collections.
pub use slice::{CloneSliceExt, VectorVector};
pub use str::{IntoMaybeOwned, StrVector};
pub use slice::{CloneSliceExt, SliceConcatExt};
pub use str::IntoMaybeOwned;
pub use string::{String, ToString};
pub use vec::Vec;
}
6 changes: 3 additions & 3 deletions src/libcollections/ring_buf.rs
Expand Up @@ -1137,7 +1137,7 @@ impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
}
let tail = self.tail;
self.tail = wrap_index(self.tail + 1, self.ring.len());
unsafe { Some(self.ring.unsafe_get(tail)) }
unsafe { Some(self.ring.get_unchecked(tail)) }
}

#[inline]
Expand All @@ -1154,7 +1154,7 @@ impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> {
return None;
}
self.head = wrap_index(self.head - 1, self.ring.len());
unsafe { Some(self.ring.unsafe_get(self.head)) }
unsafe { Some(self.ring.get_unchecked(self.head)) }
}
}

Expand All @@ -1173,7 +1173,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Iter<'a, T> {
None
} else {
let idx = wrap_index(self.tail + j, self.ring.len());
unsafe { Some(self.ring.unsafe_get(idx)) }
unsafe { Some(self.ring.get_unchecked(idx)) }
}
}
}
Expand Down

5 comments on commit 6abfac0

@bors
Copy link
Contributor

@bors bors commented on 6abfac0 Dec 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at aturon@6abfac0

@bors
Copy link
Contributor

@bors bors commented on 6abfac0 Dec 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging aturon/rust/stab-2-vec-slice = 6abfac0 into auto

@bors
Copy link
Contributor

@bors bors commented on 6abfac0 Dec 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status: {"merge_sha": "7a22c8890cb9d1f6fe649e123a5d35b202dadb5e"}

@bors
Copy link
Contributor

@bors bors commented on 6abfac0 Dec 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aturon/rust/stab-2-vec-slice = 6abfac0 merged ok, testing candidate = 7a22c889

Please sign in to comment.