diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 6f8a3ad83a3eb..bbfba84cc9e66 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -788,7 +788,7 @@ fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) -> let exe_file = make_exe_name(config, testfile); // FIXME (#9639): This needs to handle non-utf8 paths args.push(exe_file.as_str().unwrap().to_owned()); - let prog = args.shift(); + let prog = args.shift().unwrap(); return ProcArgs {prog: prog, args: args}; } diff --git a/src/libextra/dlist.rs b/src/libextra/dlist.rs index 009cc53289e43..115700e7408a3 100644 --- a/src/libextra/dlist.rs +++ b/src/libextra/dlist.rs @@ -1053,7 +1053,7 @@ mod tests { } 1 => { m.pop_front(); - if v.len() > 0 { v.shift(); } + v.shift(); } 2 | 4 => { m.push_front(-i); diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 26b20fb49dc74..7ecf2b1e18c42 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -190,7 +190,7 @@ pub fn describe_debug_flags() { pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) { let mut args = args.to_owned(); - let binary = args.shift(); + let binary = args.shift().unwrap(); if args.is_empty() { usage(binary); return; } diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index e780864ffd507..7e6db24a4a319 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -524,7 +524,7 @@ impl<'a> Context<'a> { // rollback self.is_doc_hidden = old_is_doc_hidden; pushed.times(|| { - let (lint, lvl, src) = self.lint_stack.pop(); + let (lint, lvl, src) = self.lint_stack.pop().unwrap(); self.set_level(lint, lvl, src); }) } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 928482b64dfa2..745273a1d74be 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -370,7 +370,7 @@ mod test { impl Reader for ShortReader { fn read(&mut self, _: &mut [u8]) -> Option { - self.lengths.shift_opt() + self.lengths.shift() } } diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index aac565f2c45e9..80dbaebe01c04 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -519,7 +519,7 @@ pub struct Directories { impl Iterator for Directories { fn next(&mut self) -> Option { - match self.stack.shift_opt() { + match self.stack.shift() { Some(path) => { if path.is_dir() { self.stack.push_all_move(readdir(&path)); diff --git a/src/libstd/str.rs b/src/libstd/str.rs index ff029565cf1a4..f59cd855c32c9 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -703,7 +703,7 @@ impl<'a> Iterator for Normalizations<'a> { self.sorted = true; } - match self.buffer.shift_opt() { + match self.buffer.shift() { Some((c, 0)) => { self.sorted = false; Some(c) diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 1dfd2ea560008..6300abb55a199 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1383,10 +1383,8 @@ pub trait OwnedVector { fn push_all_move(&mut self, rhs: ~[T]); /// Remove the last element from a vector and return it, or `None` if it is empty fn pop(&mut self) -> Option; - /// Removes the first element from a vector and return it - fn shift(&mut self) -> T; /// Removes the first element from a vector and return it, or `None` if it is empty - fn shift_opt(&mut self) -> Option; + fn shift(&mut self) -> Option; /// Prepend an element to the vector fn unshift(&mut self, x: T); @@ -1578,14 +1576,11 @@ impl OwnedVector for ~[T] { #[inline] - fn shift(&mut self) -> T { - self.shift_opt().expect("shift: empty vector") - } - - fn shift_opt(&mut self) -> Option { + fn shift(&mut self) -> Option { self.remove_opt(0) } + #[inline] fn unshift(&mut self, x: T) { self.insert(0, x) } @@ -1645,7 +1640,7 @@ impl OwnedVector for ~[T] { if index < ln - 1 { self.swap(index, ln - 1); } - self.pop() + self.pop().unwrap() } fn truncate(&mut self, newlen: uint) { let oldlen = self.len(); @@ -3580,21 +3575,11 @@ mod tests { #[test] fn test_shift() { let mut x = ~[1, 2, 3]; - assert_eq!(x.shift(), 1); - assert_eq!(&x, &~[2, 3]); - assert_eq!(x.shift(), 2); - assert_eq!(x.shift(), 3); - assert_eq!(x.len(), 0); - } - - #[test] - fn test_shift_opt() { - let mut x = ~[1, 2, 3]; - assert_eq!(x.shift_opt(), Some(1)); + assert_eq!(x.shift(), Some(1)); assert_eq!(&x, &~[2, 3]); - assert_eq!(x.shift_opt(), Some(2)); - assert_eq!(x.shift_opt(), Some(3)); - assert_eq!(x.shift_opt(), None); + assert_eq!(x.shift(), Some(2)); + assert_eq!(x.shift(), Some(3)); + assert_eq!(x.shift(), None); assert_eq!(x.len(), 0); } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 4d5c4ec24f305..6ad2d8f8c8d66 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -65,7 +65,7 @@ fn shift_push() { let mut v2 = ~[]; while v1.len() > 0 { - v2.push(v1.shift()); + v2.push(v1.shift().unwrap()); } }