]> git.lizzy.rs Git - rust.git/commitdiff
[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behavior
authorSimon Sapin <simon.sapin@exyr.org>
Mon, 23 Dec 2013 15:20:52 +0000 (16:20 +0100)
committerSimon Sapin <simon.sapin@exyr.org>
Tue, 21 Jan 2014 23:48:47 +0000 (15:48 -0800)
43 files changed:
src/compiletest/header.rs
src/compiletest/runtest.rs
src/libextra/dlist.rs
src/libextra/ebml.rs
src/libextra/glob.rs
src/libextra/json.rs
src/libextra/priority_queue.rs
src/libextra/terminfo/parm.rs
src/libextra/test.rs
src/libextra/treemap.rs
src/libgreen/sched.rs
src/librustc/middle/borrowck/gather_loans/mod.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/dead.rs
src/librustc/middle/reachable.rs
src/librustc/middle/trans/cleanup.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/check/regionmanip.rs
src/librustc/middle/typeck/infer/mod.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/librustc/middle/typeck/infer/resolve.rs
src/librustdoc/html/render.rs
src/librustpkg/crate_id.rs
src/libstd/io/process.rs
src/libstd/num/strconv.rs
src/libstd/path/posix.rs
src/libstd/path/windows.rs
src/libstd/repr.rs
src/libstd/vec.rs
src/libsyntax/ast_map.rs
src/libsyntax/ast_util.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/build.rs
src/libsyntax/ext/deriving/generic.rs
src/libsyntax/ext/registrar.rs
src/libsyntax/ext/tt/macro_parser.rs
src/libsyntax/ext/tt/transcribe.rs
src/libsyntax/opt_vec.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pp.rs
src/libsyntax/print/pprust.rs
src/test/bench/msgsend-ring-mutex-arcs.rs
src/test/bench/msgsend-ring-rw-arcs.rs

index 54d99151233ea27489f0436782b099185945c503..ee4d74ce1698b884ae825125c137b104a5a8e2be 100644 (file)
@@ -159,10 +159,10 @@ fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
         let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
 
         match strs.len() {
-          1u => (strs.pop(), ~""),
+          1u => (strs.pop().unwrap(), ~""),
           2u => {
-              let end = strs.pop();
-              (strs.pop(), end)
+              let end = strs.pop().unwrap();
+              (strs.pop().unwrap(), end)
           }
           n => fail!("Expected 1 or 2 strings, not {}", n)
         }
index e06f4e32631203da3bb6dc95b303af8c22cdd2df..6f8a3ad83a3ebafa5484a32aa4b8f6b79b4d16dd 100644 (file)
@@ -917,7 +917,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
 
     // get bare program string
     let mut tvec: ~[~str] = args.prog.split('/').map(|ts| ts.to_owned()).collect();
-    let prog_short = tvec.pop();
+    let prog_short = tvec.pop().unwrap();
 
     // copy to target
     let copy_result = procsrv::run("", config.adb_path,
index 28a6c69ba1b6df499e308693b6e63d5ddfeef658..009cc53289e43831064de3030e13b02e10a2504d 100644 (file)
@@ -1049,7 +1049,7 @@ fn fuzz_test(sz: int) {
             match r % 6 {
                 0 => {
                     m.pop_back();
-                    if v.len() > 0 { v.pop(); }
+                    v.pop();
                 }
                 1 => {
                     m.pop_front();
index f7481599bacfb42795fc7cad8b406fb3142b5ce4..8cce47b03f80b178aa971a7bd79598066abcca65 100644 (file)
@@ -651,7 +651,7 @@ pub fn start_tag(&mut self, tag_id: uint) {
         }
 
         pub fn end_tag(&mut self) {
-            let last_size_pos = self.size_positions.pop();
+            let last_size_pos = self.size_positions.pop().unwrap();
             let cur_pos = self.writer.tell();
             self.writer.seek(last_size_pos as i64, io::SeekSet);
             let size = (cur_pos as uint - last_size_pos - 4);
index d4d0a7b89f040141d74096848e4831dcdf71ae5f..3e2aa511b81fccd4f172a26f918c942cd192b153 100644 (file)
@@ -122,7 +122,7 @@ fn next(&mut self) -> Option<Path> {
                 return None;
             }
 
-            let (path,idx) = self.todo.pop();
+            let (path,idx) = self.todo.pop().unwrap();
             let ref pattern = self.dir_patterns[idx];
 
             if pattern.matches_with(match path.filename_str() {
index 378e1e85339ffdf06e81c7104ef03555fe0f69ee..9fcafee8c51bb3900d7caa87fdf88dd860b8e0d8 100644 (file)
@@ -1028,7 +1028,7 @@ fn parse_object(&mut self) -> Result<Json, Error> {
         while !self.eof() {
             self.parse_whitespace();
 
-            if self.ch != '\"' {
+            if self.ch != '"' {
                 return self.error(~"key must be a string");
             }
 
@@ -1117,7 +1117,7 @@ fn expected(&self, expected: &str, found: &Json) -> ! {
 impl serialize::Decoder for Decoder {
     fn read_nil(&mut self) -> () {
         debug!("read_nil");
-        match self.stack.pop() {
+        match self.stack.pop().unwrap() {
             Null => (),
             value => self.expected("null", &value)
         }
@@ -1137,7 +1137,7 @@ fn read_int(&mut self) -> int { self.read_f64() as int }
 
     fn read_bool(&mut self) -> bool {
         debug!("read_bool");
-        match self.stack.pop() {
+        match self.stack.pop().unwrap() {
             Boolean(b) => b,
             value => self.expected("boolean", &value)
         }
@@ -1145,7 +1145,7 @@ fn read_bool(&mut self) -> bool {
 
     fn read_f64(&mut self) -> f64 {
         debug!("read_f64");
-        match self.stack.pop() {
+        match self.stack.pop().unwrap() {
             Number(f) => f,
             value => self.expected("number", &value)
         }
@@ -1168,7 +1168,7 @@ fn read_char(&mut self) -> char {
 
     fn read_str(&mut self) -> ~str {
         debug!("read_str");
-        match self.stack.pop() {
+        match self.stack.pop().unwrap() {
             String(s) => s,
             value => self.expected("string", &value)
         }
@@ -1184,7 +1184,7 @@ fn read_enum_variant<T>(&mut self,
                             f: |&mut Decoder, uint| -> T)
                             -> T {
         debug!("read_enum_variant(names={:?})", names);
-        let name = match self.stack.pop() {
+        let name = match self.stack.pop().unwrap() {
             String(s) => s,
             Object(mut o) => {
                 let n = match o.pop(&~"variant") {
@@ -1249,7 +1249,7 @@ fn read_struct<T>(&mut self,
                       -> T {
         debug!("read_struct(name={}, len={})", name, len);
         let value = f(self);
-        self.stack.pop();
+        self.stack.pop().unwrap();
         value
     }
 
@@ -1259,7 +1259,7 @@ fn read_struct_field<T>(&mut self,
                             f: |&mut Decoder| -> T)
                             -> T {
         debug!("read_struct_field(name={}, idx={})", name, idx);
-        match self.stack.pop() {
+        match self.stack.pop().unwrap() {
             Object(mut obj) => {
                 let value = match obj.pop(&name.to_owned()) {
                     None => self.missing_field(name, obj),
@@ -1302,7 +1302,7 @@ fn read_tuple_struct_arg<T>(&mut self,
     }
 
     fn read_option<T>(&mut self, f: |&mut Decoder, bool| -> T) -> T {
-        match self.stack.pop() {
+        match self.stack.pop().unwrap() {
             Null => f(self, false),
             value => { self.stack.push(value); f(self, true) }
         }
@@ -1310,7 +1310,7 @@ fn read_option<T>(&mut self, f: |&mut Decoder, bool| -> T) -> T {
 
     fn read_seq<T>(&mut self, f: |&mut Decoder, uint| -> T) -> T {
         debug!("read_seq()");
-        let len = match self.stack.pop() {
+        let len = match self.stack.pop().unwrap() {
             List(list) => {
                 let len = list.len();
                 for v in list.move_rev_iter() {
@@ -1330,7 +1330,7 @@ fn read_seq_elt<T>(&mut self, idx: uint, f: |&mut Decoder| -> T) -> T {
 
     fn read_map<T>(&mut self, f: |&mut Decoder, uint| -> T) -> T {
         debug!("read_map()");
-        let len = match self.stack.pop() {
+        let len = match self.stack.pop().unwrap() {
             Object(obj) => {
                 let len = obj.len();
                 for (key, value) in obj.move_iter() {
index 9b6d12580ecc44020953698d17a0874b04f38f95..33b3931e9897a1eb7e5b28677a62d2e74ce910c9 100644 (file)
@@ -59,7 +59,7 @@ pub fn reserve_at_least(&mut self, n: uint) {
 
     /// Pop the greatest item from the queue - fails if empty
     pub fn pop(&mut self) -> T {
-        let mut item = self.data.pop();
+        let mut item = self.data.pop().unwrap();
         if !self.is_empty() {
             swap(&mut item, &mut self.data[0]);
             self.siftdown(0);
@@ -235,7 +235,7 @@ fn test_top_and_pop() {
         let mut heap = PriorityQueue::from_vec(data);
         while !heap.is_empty() {
             assert_eq!(heap.top(), sorted.last().unwrap());
-            assert_eq!(heap.pop(), sorted.pop());
+            assert_eq!(heap.pop(), sorted.pop().unwrap());
         }
     }
 
index eac450d9562f2c34fb8f267569911268f69ea962..bd9eadc078d1bf57fafac98033f68bec5ea8c25c 100644 (file)
@@ -121,7 +121,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                 match cur {
                     '%' => { output.push(c); state = Nothing },
                     'c' => if stack.len() > 0 {
-                        match stack.pop() {
+                        match stack.pop().unwrap() {
                             // if c is 0, use 0200 (128) for ncurses compatibility
                             Number(c) => output.push(if c == 0 { 128 } else { c } as u8),
                             _       => return Err(~"a non-char was used with %c")
@@ -133,82 +133,82 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                     '\'' => state = CharConstant,
                     '{' => state = IntConstant(0),
                     'l' => if stack.len() > 0 {
-                        match stack.pop() {
+                        match stack.pop().unwrap() {
                             String(s) => stack.push(Number(s.len() as int)),
                             _         => return Err(~"a non-str was used with %l")
                         }
                     } else { return Err(~"stack is empty") },
                     '+' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(x + y)),
                             _ => return Err(~"non-numbers on stack with +")
                         }
                     } else { return Err(~"stack is empty") },
                     '-' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(x - y)),
                             _ => return Err(~"non-numbers on stack with -")
                         }
                     } else { return Err(~"stack is empty") },
                     '*' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(x * y)),
                             _ => return Err(~"non-numbers on stack with *")
                         }
                     } else { return Err(~"stack is empty") },
                     '/' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(x / y)),
                             _ => return Err(~"non-numbers on stack with /")
                         }
                     } else { return Err(~"stack is empty") },
                     'm' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(x % y)),
                             _ => return Err(~"non-numbers on stack with %")
                         }
                     } else { return Err(~"stack is empty") },
                     '&' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(x & y)),
                             _ => return Err(~"non-numbers on stack with &")
                         }
                     } else { return Err(~"stack is empty") },
                     '|' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(x | y)),
                             _ => return Err(~"non-numbers on stack with |")
                         }
                     } else { return Err(~"stack is empty") },
                     '^' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(x ^ y)),
                             _ => return Err(~"non-numbers on stack with ^")
                         }
                     } else { return Err(~"stack is empty") },
                     '=' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(if x == y { 1 }
                                                                         else { 0 })),
                             _ => return Err(~"non-numbers on stack with =")
                         }
                     } else { return Err(~"stack is empty") },
                     '>' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(if x > y { 1 }
                                                                         else { 0 })),
                             _ => return Err(~"non-numbers on stack with >")
                         }
                     } else { return Err(~"stack is empty") },
                     '<' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(y), Number(x)) => stack.push(Number(if x < y { 1 }
                                                                         else { 0 })),
                             _ => return Err(~"non-numbers on stack with <")
                         }
                     } else { return Err(~"stack is empty") },
                     'A' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(0), Number(_)) => stack.push(Number(0)),
                             (Number(_), Number(0)) => stack.push(Number(0)),
                             (Number(_), Number(_)) => stack.push(Number(1)),
@@ -216,21 +216,21 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                         }
                     } else { return Err(~"stack is empty") },
                     'O' => if stack.len() > 1 {
-                        match (stack.pop(), stack.pop()) {
+                        match (stack.pop().unwrap(), stack.pop().unwrap()) {
                             (Number(0), Number(0)) => stack.push(Number(0)),
                             (Number(_), Number(_)) => stack.push(Number(1)),
                             _ => return Err(~"non-numbers on stack with logical or")
                         }
                     } else { return Err(~"stack is empty") },
                     '!' => if stack.len() > 0 {
-                        match stack.pop() {
+                        match stack.pop().unwrap() {
                             Number(0) => stack.push(Number(1)),
                             Number(_) => stack.push(Number(0)),
                             _ => return Err(~"non-number on stack with logical not")
                         }
                     } else { return Err(~"stack is empty") },
                     '~' => if stack.len() > 0 {
-                        match stack.pop() {
+                        match stack.pop().unwrap() {
                             Number(x) => stack.push(Number(!x)),
                             _         => return Err(~"non-number on stack with %~")
                         }
@@ -246,7 +246,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                     // printf-style support for %doxXs
                     'd'|'o'|'x'|'X'|'s' => if stack.len() > 0 {
                         let flags = Flags::new();
-                        let res = format(stack.pop(), FormatOp::from_char(cur), flags);
+                        let res = format(stack.pop().unwrap(), FormatOp::from_char(cur), flags);
                         if res.is_err() { return res }
                         output.push_all(res.unwrap())
                     } else { return Err(~"stack is empty") },
@@ -270,7 +270,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                     // conditionals
                     '?' => (),
                     't' => if stack.len() > 0 {
-                        match stack.pop() {
+                        match stack.pop().unwrap() {
                             Number(0) => state = SeekIfElse(0),
                             Number(_) => (),
                             _         => return Err(~"non-number on stack with conditional")
@@ -293,12 +293,12 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                 if cur >= 'A' && cur <= 'Z' {
                     if stack.len() > 0 {
                         let idx = (cur as u8) - ('A' as u8);
-                        vars.sta[idx] = stack.pop();
+                        vars.sta[idx] = stack.pop().unwrap();
                     } else { return Err(~"stack is empty") }
                 } else if cur >= 'a' && cur <= 'z' {
                     if stack.len() > 0 {
                         let idx = (cur as u8) - ('a' as u8);
-                        vars.dyn[idx] = stack.pop();
+                        vars.dyn[idx] = stack.pop().unwrap();
                     } else { return Err(~"stack is empty") }
                 } else {
                     return Err(~"bad variable name in %P");
@@ -341,7 +341,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                 old_state = Nothing;
                 match (*fstate, cur) {
                     (_,'d')|(_,'o')|(_,'x')|(_,'X')|(_,'s') => if stack.len() > 0 {
-                        let res = format(stack.pop(), FormatOp::from_char(cur), *flags);
+                        let res = format(stack.pop().unwrap(), FormatOp::from_char(cur), *flags);
                         if res.is_err() { return res }
                         output.push_all(res.unwrap());
                         old_state = state; // will cause state to go to Nothing
index ed3dcb5d7379b1f051b98d256a5ed7e0f94e6712..5f0270beb80e5b298246613df424936c769703f5 100644 (file)
@@ -753,7 +753,7 @@ fn run_tests(opts: &TestOpts,
 
     while pending > 0 || !remaining.is_empty() {
         while pending < concurrency && !remaining.is_empty() {
-            let test = remaining.pop();
+            let test = remaining.pop().unwrap();
             if concurrency == 1 {
                 // We are doing one test at a time so we can print the name
                 // of the test before we run it. Useful for debugging tests
index 7b8258ec5ae2763731fc803a38742558da8b393e..683fe2e070bb5a41ce5fc74d64d351ff2925cb05 100644 (file)
@@ -359,7 +359,7 @@ fn next_(&mut self, forward: bool) -> Option<(&'a K, &'a $($addr_mut)* V)> {
                         }
                         self.stack.push(node);
                     } else {
-                        let node = self.stack.pop();
+                        let node = self.stack.pop().unwrap();
                         let next_node = if forward {
                             addr!(& $($addr_mut)* node.right)
                         } else {
@@ -496,7 +496,7 @@ fn next(&mut self) -> Option<(K, V)> {
                 left: left,
                 right: right,
                 level: level
-            } = self.stack.pop();
+            } = self.stack.pop().unwrap();
 
             match left {
                 Some(~left) => {
index 3554d435e556ca58ecad078fec18c5e5e9b85fba..989b8dc31f8a8d584f8e1a489eabb866cb78f6a0 100644 (file)
@@ -1285,8 +1285,11 @@ fn multithreading() {
                 ports.push(port);
             });
 
-            while !ports.is_empty() {
-                ports.pop().recv();
+            loop {
+                match ports.pop() {
+                    Some(port) => port.recv(),
+                    None => break,
+                }
             }
         }
     }
index 14fd3799caf1b52620680fa5db37bdcc15299960..e45ea77b49e1dfcb6d3794974dd68fa3f34a5903 100644 (file)
@@ -339,7 +339,7 @@ pub fn push_repeating_id(&mut self, id: ast::NodeId) {
     }
 
     pub fn pop_repeating_id(&mut self, id: ast::NodeId) {
-        let popped = self.repeating_ids.pop();
+        let popped = self.repeating_ids.pop().unwrap();
         assert_eq!(id, popped);
     }
 
index e79d1649099d952d4567cbe93f2d9ff8465c10d3..835f53a50ac795288ff6e9755c6f5f87c6446647 100644 (file)
@@ -504,7 +504,7 @@ fn walk_expr(&mut self,
 
                     // add the bits from any early return via `break`,
                     // `continue`, or `return` into `func_bits`
-                    let loop_scope = loop_scopes.pop();
+                    let loop_scope = loop_scopes.pop().unwrap();
                     join_bits(&self.dfcx.oper, loop_scope.break_bits, func_bits);
 
                     // add `func_bits` to the entry bits for `expr`,
@@ -563,7 +563,7 @@ fn walk_expr(&mut self,
                 });
                 self.walk_block(blk, body_bits, loop_scopes);
                 self.add_to_entry_set(expr.id, body_bits);
-                let new_loop_scope = loop_scopes.pop();
+                let new_loop_scope = loop_scopes.pop().unwrap();
                 copy_bits(new_loop_scope.break_bits, in_out);
             }
 
@@ -588,7 +588,7 @@ fn walk_expr(&mut self,
                 self.walk_block(blk, body_bits, loop_scopes);
                 self.add_to_entry_set(expr.id, body_bits);
 
-                let new_loop_scope = loop_scopes.pop();
+                let new_loop_scope = loop_scopes.pop().unwrap();
                 assert_eq!(new_loop_scope.loop_id, expr.id);
                 copy_bits(new_loop_scope.break_bits, in_out);
             }
index 746cc74d7f6f1a01b72b21c3147b3faa4af07151..c333bc58feee12975650a1b9455a70c0f43c58e6 100644 (file)
@@ -129,7 +129,7 @@ fn lookup_and_handle_method(&mut self, id: &ast::NodeId,
     fn mark_live_symbols(&mut self) {
         let mut scanned = HashSet::new();
         while self.worklist.len() > 0 {
-            let id = self.worklist.pop();
+            let id = self.worklist.pop().unwrap();
             if scanned.contains(&id) {
                 continue
             }
index 6f8ad77e90b2d83346d67386542a0f206a5129fe..66d706e3621c10b53d45140e8b10e7bbbd600cff 100644 (file)
@@ -284,7 +284,7 @@ fn propagate(&self) {
                 if worklist.get().len() == 0 {
                     break
                 }
-                let search_item = worklist.get().pop();
+                let search_item = worklist.get().pop().unwrap();
                 if scanned.contains(&search_item) {
                     continue
                 }
index d4b9af17845468256cfba055158e3ea8283b2a4d..1f0e99de264a86c5a8230caf4587294bdebb2f01 100644 (file)
@@ -396,8 +396,11 @@ fn get_landing_pad(&self) -> BasicBlockRef {
         let llbb = self.get_or_create_landing_pad();
 
         // Push the scopes we removed back on:
-        while !popped_scopes.is_empty() {
-            self.push_scope(popped_scopes.pop());
+        loop {
+            match popped_scopes.pop() {
+                Some(scope) => self.push_scope(scope),
+                None => break
+            }
         }
 
         assert_eq!(self.scopes_len(), orig_scopes_len);
@@ -470,7 +473,7 @@ fn pop_scope(&self) -> CleanupScope<'a> {
                self.scopes_len() - 1);
 
         let mut scopes = self.scopes.borrow_mut();
-        scopes.get().pop()
+        scopes.get().pop().unwrap()
     }
 
     fn top_scope<R>(&self, f: |&CleanupScope<'a>| -> R) -> R {
@@ -608,7 +611,7 @@ fn trans_cleanups_to_exit_scope(&self,
         // At this point, `popped_scopes` is empty, and so the final block
         // that we return to the user is `Cleanup(AST 24)`.
         while !popped_scopes.is_empty() {
-            let mut scope = popped_scopes.pop();
+            let mut scope = popped_scopes.pop().unwrap();
 
             if scope.cleanups.iter().any(|c| cleanup_is_suitable_for(*c, label))
             {
index 31ac97965b95bab1dea0ab657a911dc1eeab03ba..01fb18d73c26a5efa6ae110653e34b2847b19c91 100644 (file)
@@ -2336,7 +2336,7 @@ fn subtypes_require(cx: ctxt, seen: &mut ~[DefId],
                 seen.push(did);
                 let fields = struct_fields(cx, did, substs);
                 let r = fields.iter().any(|f| type_requires(cx, seen, r_ty, f.mt.ty));
-                seen.pop();
+                seen.pop().unwrap();
                 r
             }
 
@@ -2357,7 +2357,7 @@ fn subtypes_require(cx: ctxt, seen: &mut ~[DefId],
                         type_requires(cx, seen, r_ty, sty)
                     })
                 });
-                seen.pop();
+                seen.pop().unwrap();
                 r
             }
         };
index c8fde97e4d6b3915512def1344d3c0b3763e39ac..daf5bdd9ea3158c5a3468edaadd6282b4c5bcd62 100644 (file)
@@ -107,7 +107,7 @@ fn fold_ty(&mut self, ty: ty::t) -> ty::t {
                     self.relate(r);
                     self.stack.push(r);
                     ty_fold::super_fold_ty(self, mt.ty);
-                    self.stack.pop();
+                    self.stack.pop().unwrap();
                 }
 
                 _ => {
index cb714399c16524b9e494a0aa57991100e4ae5304..68fb4b1e579a6d5204398055fd8cd9d5dd8e5b49 100644 (file)
@@ -489,7 +489,7 @@ pub fn uok() -> ures {
 fn rollback_to<V:Clone + Vid,T:Clone>(vb: &mut ValsAndBindings<V, T>,
                                       len: uint) {
     while vb.bindings.len() != len {
-        let (vid, old_v) = vb.bindings.pop();
+        let (vid, old_v) = vb.bindings.pop().unwrap();
         vb.vals.insert(vid.to_uint(), old_v);
     }
 }
index b5e67361378a9d48376a2a5feb295c883d9e09ed..536bbd0b20da031b1e62cfe45bf276832ce7abd6 100644 (file)
@@ -150,7 +150,7 @@ pub fn commit(&self) {
         debug!("RegionVarBindings: commit()");
         let mut undo_log = self.undo_log.borrow_mut();
         while undo_log.get().len() > 0 {
-            undo_log.get().pop();
+            undo_log.get().pop().unwrap();
         }
     }
 
@@ -158,14 +158,14 @@ pub fn rollback_to(&self, snapshot: uint) {
         debug!("RegionVarBindings: rollback_to({})", snapshot);
         let mut undo_log = self.undo_log.borrow_mut();
         while undo_log.get().len() > snapshot {
-            let undo_item = undo_log.get().pop();
+            let undo_item = undo_log.get().pop().unwrap();
             debug!("undo_item={:?}", undo_item);
             match undo_item {
               Snapshot => {}
               AddVar(vid) => {
                 let mut var_origins = self.var_origins.borrow_mut();
                 assert_eq!(var_origins.get().len(), vid.to_uint() + 1);
-                var_origins.get().pop();
+                var_origins.get().pop().unwrap();
               }
               AddConstraint(ref constraint) => {
                 let mut constraints = self.constraints.borrow_mut();
@@ -1234,7 +1234,7 @@ struct WalkState {
         process_edges(self, &mut state, graph, orig_node_idx, dir);
 
         while !state.stack.is_empty() {
-            let node_idx = state.stack.pop();
+            let node_idx = state.stack.pop().unwrap();
             let classification = var_data[node_idx.to_uint()].classification;
 
             // check whether we've visited this node on some previous walk
index 498f4707f92b7983a0e08a00a452d033eb87caf5..85585ecaf5483b005645684fff77b3d5d242b4a1 100644 (file)
@@ -242,7 +242,7 @@ pub fn resolve_ty_var(&mut self, vid: TyVid) -> ty::t {
                 ty::mk_var(tcx, vid)
               }
             };
-            self.v_seen.pop();
+            self.v_seen.pop().unwrap();
             return t1;
         }
     }
index fee97232fa000ee664dfae9f31fbde1bc89c8f3e..9a9b588fa4782afd66d2f6eb0c5a2d73ec0ce1fd 100644 (file)
@@ -635,8 +635,8 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
             i => i,
         };
 
-        if pushed { self.stack.pop(); }
-        if parent_pushed { self.parent_stack.pop(); }
+        if pushed { self.stack.pop().unwrap(); }
+        if parent_pushed { self.parent_stack.pop().unwrap(); }
         self.privmod = orig_privmod;
         return ret;
     }
@@ -673,7 +673,7 @@ fn recurse<T>(&mut self, s: ~str, f: |&mut Context| -> T) -> T {
         self.dst = prev;
         let len = self.root_path.len();
         self.root_path.truncate(len - 3);
-        self.current.pop();
+        self.current.pop().unwrap();
 
         return ret;
     }
@@ -693,11 +693,13 @@ fn crate(mut self, mut crate: clean::Crate, cache: Cache) {
         local_data::set(cache_key, Arc::new(cache));
 
         let mut work = ~[(self, item)];
-        while work.len() > 0 {
-            let (mut cx, item) = work.pop();
-            cx.item(item, |cx, item| {
-                work.push((cx.clone(), item));
-            })
+        loop {
+            match work.pop() {
+                Some((mut cx, item)) => cx.item(item, |cx, item| {
+                    work.push((cx.clone(), item));
+                }),
+                None => break,
+            }
         }
     }
 
index 9a3c47823e07b86d04d57be6ca35b1d8699890fe..239abbe546ff0ddfecd1bfe00fb3ae8c196ebfde 100644 (file)
@@ -121,7 +121,7 @@ fn next(&mut self) -> Option<(Path, Path)> {
             None
         }
         else {
-            let last = self.components.pop();
+            let last = self.components.pop().unwrap();
             self.remaining.unshift(last);
             // converting to str and then back is a little unfortunate
             Some((Path::new(self.components.connect("/")),
index 4c8a640a849c12f3b92b8ccb03d96046135fb5ab..a0c451647d34ac04caff8bd5f62208339c64fa17 100644 (file)
@@ -161,8 +161,11 @@ impl Drop for Process {
     fn drop(&mut self) {
         // Close all I/O before exiting to ensure that the child doesn't wait
         // forever to print some text or something similar.
-        for _ in range(0, self.io.len()) {
-            self.io.pop();
+        loop {
+            match self.io.pop() {
+                Some(_) => (),
+                None => break,
+            }
         }
 
         self.wait();
index 0c41c538c6c498181a1b5e3c6b1794cc6cd0c241..5c35c500e6c243ca6a07e9aceb52f577b172f38f 100644 (file)
@@ -351,7 +351,7 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
                 char::from_digit(val, radix).unwrap() as u8
             };
 
-            let extra_digit = ascii2value(buf.pop());
+            let extra_digit = ascii2value(buf.pop().unwrap());
             if extra_digit >= radix / 2 { // -> need to round
                 let mut i: int = buf.len() as int - 1;
                 loop {
index b228dc7f1ffbd372ced3f015b908eb8b58d5d9a5..dc547d702ba29e5da9c28fa9df31500017465b8e 100644 (file)
@@ -426,7 +426,7 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<~[&'a [u8]]> {
         else if comp == bytes!("..") {
             if is_abs && comps.is_empty() { changed = true }
             else if comps.len() == n_up { comps.push(dot_dot_static); n_up += 1 }
-            else { comps.pop(); changed = true }
+            else { comps.pop().unwrap(); changed = true }
         } else { comps.push(comp) }
     }
     if changed {
index 0e5b7894e748cfb192d8af27ce3b39a9f7f6de53..89640add7d05d974282c2e7c1c0db23b31316dcd 100644 (file)
@@ -1025,7 +1025,7 @@ fn normalize_helper<'a>(s: &'a str, prefix: Option<PathPrefix>) -> (bool,Option<
             };
             if (is_abs || has_abs_prefix) && comps.is_empty() { changed = true }
             else if comps.len() == n_up { comps.push(".."); n_up += 1 }
-            else { comps.pop(); changed = true }
+            else { comps.pop().unwrap(); changed = true }
         } else { comps.push(comp) }
     }
     if !changed && !prefix_is_verbatim(prefix) {
index 7255448bd2395324bf08dea6fc90708e1f51f21d..8f7d01f263dd14dfaf931a4a2ccf416344e19a9f 100644 (file)
@@ -123,7 +123,7 @@ fn push_ptr(&mut self) {
         self.ptr_stk.push(self.ptr);
     }
     fn pop_ptr(&mut self) {
-        self.ptr = self.ptr_stk.pop();
+        self.ptr = self.ptr_stk.pop().unwrap();
     }
 }
 
@@ -471,7 +471,7 @@ fn visit_enter_enum_variant(&mut self, _variant: uint,
                                 n_fields: uint,
                                 name: &str) -> bool {
         let mut write = false;
-        match self.var_stk.pop() {
+        match self.var_stk.pop().unwrap() {
             SearchingFor(sought) => {
                 if disr_val == sought {
                     self.var_stk.push(Matched);
@@ -534,7 +534,7 @@ fn visit_leave_enum(&mut self,
                         _sz: uint,
                         _align: uint)
                         -> bool {
-        match self.var_stk.pop() {
+        match self.var_stk.pop().unwrap() {
             SearchingFor(..) => fail!("enum value matched no variant"),
             _ => true
         }
index b3d0e9cb10ab8daf9a2c2c19b6eef8b441b73ae6..1dfd2ea560008cbed8258eee3db493d2f783e30e 100644 (file)
@@ -1381,10 +1381,8 @@ pub trait OwnedVector<T> {
     /// assert!(a == ~[~1, ~2, ~3, ~4]);
     /// ```
     fn push_all_move(&mut self, rhs: ~[T]);
-    /// Remove the last element from a vector and return it, failing if it is empty
-    fn pop(&mut self) -> T;
     /// Remove the last element from a vector and return it, or `None` if it is empty
-    fn pop_opt(&mut self) -> Option<T>;
+    fn pop(&mut self) -> Option<T>;
     /// 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
@@ -1565,7 +1563,7 @@ fn push_all_move(&mut self, mut rhs: ~[T]) {
         }
     }
 
-    fn pop_opt(&mut self) -> Option<T> {
+    fn pop(&mut self) -> Option<T> {
         match self.len() {
             0  => None,
             ln => {
@@ -1579,11 +1577,6 @@ fn pop_opt(&mut self) -> Option<T> {
     }
 
 
-    #[inline]
-    fn pop(&mut self) -> T {
-        self.pop_opt().expect("pop: empty vector")
-    }
-
     #[inline]
     fn shift(&mut self) -> T {
         self.shift_opt().expect("shift: empty vector")
@@ -3168,28 +3161,16 @@ fn test_slice_to() {
         assert_eq!(vec.slice_to(0), &[]);
     }
 
-    #[test]
-    fn test_pop() {
-        // Test on-heap pop.
-        let mut v = ~[1, 2, 3, 4, 5];
-        let e = v.pop();
-        assert_eq!(v.len(), 4u);
-        assert_eq!(v[0], 1);
-        assert_eq!(v[1], 2);
-        assert_eq!(v[2], 3);
-        assert_eq!(v[3], 4);
-        assert_eq!(e, 5);
-    }
 
     #[test]
-    fn test_pop_opt() {
+    fn test_pop() {
         let mut v = ~[5];
-        let e = v.pop_opt();
+        let e = v.pop();
         assert_eq!(v.len(), 0);
         assert_eq!(e, Some(5));
-        let f = v.pop_opt();
+        let f = v.pop();
         assert_eq!(f, None);
-        let g = v.pop_opt();
+        let g = v.pop();
         assert_eq!(g, None);
     }
 
index 72ab81d8657584140c237907838bed2d75a86307..0585f1abecc0c0aab585d1d5b4043883f1f16f42 100644 (file)
@@ -340,7 +340,7 @@ fn fold_item(&mut self, i: @Item) -> SmallVector<@Item> {
             _ => {}
         }
 
-        self.path.pop();
+        self.path.pop().unwrap();
 
         SmallVector::one(i)
     }
index 6472551b049fc547b0e02f8972937cc72a76aa7c..47ae146d19b31b87d4cc1f569391726a6994067f 100644 (file)
@@ -904,7 +904,7 @@ pub fn mtwt_outer_mark(ctxt: SyntaxContext) -> Mrk {
 /// case pop and discard (so two of the same marks cancel)
 pub fn xorPush(marks: &mut ~[Mrk], mark: Mrk) {
     if (marks.len() > 0) && (getLast(marks) == mark) {
-        marks.pop();
+        marks.pop().unwrap();
     } else {
         marks.push(mark);
     }
index a90e118d02b9de334fffe8a6ddc38c4c0c3a4678..86982201303507736fd75150af2225fd97178693 100644 (file)
@@ -356,7 +356,7 @@ pub fn call_site(&self) -> Span {
     pub fn print_backtrace(&self) { }
     pub fn backtrace(&self) -> Option<@ExpnInfo> { self.backtrace }
     pub fn mod_push(&mut self, i: ast::Ident) { self.mod_path.push(i); }
-    pub fn mod_pop(&mut self) { self.mod_path.pop(); }
+    pub fn mod_pop(&mut self) { self.mod_path.pop().unwrap(); }
     pub fn mod_path(&self) -> ~[ast::Ident] { self.mod_path.clone() }
     pub fn bt_push(&mut self, ei: codemap::ExpnInfo) {
         match ei {
index d702ee3ead4f6553a165114c7453b3bba6e92fe6..3c0d7aaf4f3a82a578870e060341d618ac206c66 100644 (file)
@@ -253,7 +253,7 @@ fn path_all(&self,
                 lifetimes: OptVec<ast::Lifetime>,
                 types: ~[P<ast::Ty>])
                 -> ast::Path {
-        let last_identifier = idents.pop();
+        let last_identifier = idents.pop().unwrap();
         let mut segments: ~[ast::PathSegment] = idents.move_iter()
                                                       .map(|ident| {
             ast::PathSegment {
index cddfa7d2aa050fb28f3ad046f82f93e7001defca..fe519a31efa6b3e656ec8af74eba4ffb8e7a3e0f 100644 (file)
@@ -841,7 +841,7 @@ fn build_enum_match(&self,
                                                      matching,
                                                      matches_so_far,
                                                      match_count + 1);
-                matches_so_far.pop();
+                matches_so_far.pop().unwrap();
                 arms.push(cx.arm(trait_.span, ~[ pattern ], arm_expr));
 
                 if enum_def.variants.len() > 1 {
@@ -875,7 +875,7 @@ fn build_enum_match(&self,
                                                          new_matching,
                                                          matches_so_far,
                                                          match_count + 1);
-                    matches_so_far.pop();
+                    matches_so_far.pop().unwrap();
 
                     let arm = cx.arm(trait_.span, ~[ pattern ], arm_expr);
                     arms.push(arm);
index 265dd91d7f41b89163073b8940bb73f03409fee0..1c349c4343ac5697efb870ae60fb8eb4079589ff 100644 (file)
@@ -42,7 +42,7 @@ pub fn find_macro_registrar(diagnostic: @diagnostic::SpanHandler,
     match ctx.registrars.len() {
         0 => None,
         1 => {
-            let (node_id, _) = ctx.registrars.pop();
+            let (node_id, _) = ctx.registrars.pop().unwrap();
             Some(ast::DefId {
                 crate: ast::LOCAL_CRATE,
                 node: node_id
index dc721f15c3b85ef99c15264091716423a1d0ac38..492852c6a79760a51c34ea21f68fb572305b4244 100644 (file)
@@ -238,8 +238,11 @@ pub fn parse(sess: @ParseSess,
         let TokenAndSpan {tok: tok, sp: sp} = rdr.peek();
 
         /* we append new items to this while we go */
-        while !cur_eis.is_empty() { /* for each Earley Item */
-            let ei = cur_eis.pop();
+        loop {
+            let ei = match cur_eis.pop() {
+                None => break, /* for each Earley Item */
+                Some(ei) => ei,
+            };
 
             let idx = ei.idx;
             let len = ei.elts.len();
@@ -347,7 +350,7 @@ pub fn parse(sess: @ParseSess,
             if eof_eis.len() == 1u {
                 let mut v = ~[];
                 for dv in eof_eis[0u].matches.mut_iter() {
-                    v.push(dv.pop());
+                    v.push(dv.pop().unwrap());
                 }
                 return Success(nameize(sess, ms, v));
             } else if eof_eis.len() > 1u {
@@ -376,13 +379,13 @@ pub fn parse(sess: @ParseSess,
             } else if next_eis.len() > 0u {
                 /* Now process the next token */
                 while next_eis.len() > 0u {
-                    cur_eis.push(next_eis.pop());
+                    cur_eis.push(next_eis.pop().unwrap());
                 }
                 rdr.next_token();
             } else /* bb_eis.len() == 1 */ {
                 let mut rust_parser = Parser(sess, cfg.clone(), rdr.dup());
 
-                let mut ei = bb_eis.pop();
+                let mut ei = bb_eis.pop().unwrap();
                 match ei.elts[ei.idx].node {
                   MatchNonterminal(_, ref name, idx) => {
                     ei.matches[idx].push(@MatchedNonterminal(
index 4c78244bf08435c308c2c2fb17a8c4f9bcafca55..20d544f52c90f8a035a89f5ad0a9e57064ec52a2 100644 (file)
@@ -204,8 +204,8 @@ pub fn tt_next_token(r: &TtReader) -> TokenAndSpan {
                     {
                         let mut repeat_idx = r.repeat_idx.borrow_mut();
                         let mut repeat_len = r.repeat_len.borrow_mut();
-                        repeat_idx.get().pop();
-                        repeat_len.get().pop();
+                        repeat_idx.get().pop().unwrap();
+                        repeat_len.get().pop().unwrap();
                     }
                 }
 
index d6f363eb6a074a06a8a9bc54bdb8151b88d27c00..ce3042cb9cde5d6ea2be5cde9991010f03836b53 100644 (file)
@@ -48,10 +48,10 @@ pub fn push(&mut self, t: T) {
         }
     }
 
-    pub fn pop(&mut self) -> T {
+    pub fn pop(&mut self) -> Option<T> {
         match *self {
             Vec(ref mut v) => v.pop(),
-            Empty => fail!("pop from empty opt_vec")
+            Empty => None
         }
     }
 
index 30408fa1c2b53790b9e05214431537ebf7e018ea..4e1703fe6b0c796e42550234d017f7659a8cb657 100644 (file)
@@ -2158,7 +2158,7 @@ fn parse_any_tt_tok(p: &mut Parser) -> TokenTree {
 
                 // Parse the close delimiter.
                 result.push(parse_any_tt_tok(self));
-                self.open_braces.pop();
+                self.open_braces.pop().unwrap();
 
                 TTDelim(@result)
             }
@@ -3593,7 +3593,7 @@ fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
                 }
             );
 
-        let variadic = match args.pop_opt() {
+        let variadic = match args.pop() {
             Some(None) => true,
             Some(x) => {
                 // Need to put back that last arg
@@ -4218,7 +4218,7 @@ fn push_mod_path(&mut self, id: Ident, attrs: &[Attribute]) {
     }
 
     fn pop_mod_path(&mut self) {
-        self.mod_path_stack.pop();
+        self.mod_path_stack.pop().unwrap();
     }
 
     // read a module from a source file.
index c421c2f4d7afdaffc7001919af136ad652bc085e..902d9e1c28468e16e933c5278a41eb4189367e20 100644 (file)
@@ -511,7 +511,7 @@ pub fn print(&mut self, x: Token, L: int) {
             debug!("print End -> pop End");
             let print_stack = &mut self.print_stack;
             assert!((print_stack.len() != 0u));
-            print_stack.pop();
+            print_stack.pop().unwrap();
           }
           Break(b) => {
             let top = self.get_top();
index 3ea48969069ce300d05b9345099c34bfdd962f4f..cdfeebd3e1bc88e3df3022ff73ef6c6515c88fa7 100644 (file)
@@ -78,7 +78,7 @@ pub fn ibox(s: &mut State, u: uint) {
 pub fn end(s: &mut State) {
     {
         let mut boxes = s.boxes.borrow_mut();
-        boxes.get().pop();
+        boxes.get().pop().unwrap();
     }
     pp::end(&mut s.s);
 }
@@ -1090,11 +1090,11 @@ pub fn print_call_pre(s: &mut State,
     match sugar {
         ast::DoSugar => {
             head(s, "do");
-            Some(base_args.pop())
+            Some(base_args.pop().unwrap())
         }
         ast::ForSugar => {
             head(s, "for");
-            Some(base_args.pop())
+            Some(base_args.pop().unwrap())
         }
         ast::NoSugar => None
     }
index b148df248334d3329d7278aabd4ccaf33e85ee04..a5838f2017385f56bcda105ce7c03b2e8fe7bfec 100644 (file)
@@ -40,7 +40,7 @@ fn recv(p: &pipe) -> uint {
             while state.is_empty() {
                 cond.wait();
             }
-            state.pop()
+            state.pop().unwrap()
         })
     }
 }
index ea241d267c7ce57edee404a7ee5aa5a5ae95d9c1..fa7026b6569f9dfb16eeb6e463b406e267e1a440 100644 (file)
@@ -37,7 +37,7 @@ fn recv(p: &pipe) -> uint {
         while state.is_empty() {
             cond.wait();
         }
-        state.pop()
+        state.pop().unwrap()
     })
 }