about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2012-08-15 11:55:17 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2012-08-15 12:38:32 -0700
commit51d98d9c7bcdfad2daec697739b25193adc09ced (patch)
treec4ae164ad57499113d0cc2e4b82f6406acb82e1f
parentb0f289397ce47ed8c4d4f97d94408e83a59abd5a (diff)
downloadrust-51d98d9c7bcdfad2daec697739b25193adc09ced.tar.gz
rust-51d98d9c7bcdfad2daec697739b25193adc09ced.zip
Expunge match checks
-rw-r--r--src/libcore/comm.rs5
-rw-r--r--src/libcore/run.rs6
-rw-r--r--src/libcore/str.rs10
-rw-r--r--src/libstd/base64.rs11
-rw-r--r--src/libstd/ebml.rs9
-rw-r--r--src/libstd/getopts.rs3
-rw-r--r--src/libstd/list.rs6
-rw-r--r--src/libstd/serialization.rs7
-rw-r--r--src/libstd/time.rs25
9 files changed, 54 insertions, 28 deletions
diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs
index 38bdc407547..b4cf0ef1002 100644
--- a/src/libcore/comm.rs
+++ b/src/libcore/comm.rs
@@ -412,9 +412,10 @@ fn test_select2_stress() {
     let mut as = 0;
     let mut bs = 0;
     for iter::repeat(msgs * times * 2u) {
-        match check select2(po_a, po_b) {
+        match select2(po_a, po_b) {
           either::left(~"a") => as += 1,
-          either::right(~"b") => bs += 1
+          either::right(~"b") => bs += 1,
+          _ => fail ~"test_select_2_stress failed"
         }
     }
 
diff --git a/src/libcore/run.rs b/src/libcore/run.rs
index f754391a50d..7b08bb8f96b 100644
--- a/src/libcore/run.rs
+++ b/src/libcore/run.rs
@@ -312,13 +312,17 @@ fn program_output(prog: &str, args: &[~str]) ->
     let mut count = 2;
     while count > 0 {
         let stream = comm::recv(p);
-        match check stream {
+        match stream {
             (1, s) => {
                 outs = s;
             }
             (2, s) => {
                 errs = s;
             }
+            (n, _) => {
+                fail(#fmt("program_output received an unexpected file \
+                  number: %u", n));
+            }
         };
         count -= 1;
     };
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 181c36932d0..9a1e32a6711 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -2771,10 +2771,11 @@ mod tests {
     fn test_chars_iter() {
         let mut i = 0;
         do chars_iter(~"x\u03c0y") |ch| {
-            match check i {
+            match i {
               0 => assert ch == 'x',
               1 => assert ch == '\u03c0',
-              2 => assert ch == 'y'
+              2 => assert ch == 'y',
+              _ => fail ~"test_chars_iter failed"
             }
             i += 1;
         }
@@ -2787,10 +2788,11 @@ mod tests {
         let mut i = 0;
 
         do bytes_iter(~"xyz") |bb| {
-            match check i {
+            match i {
               0 => assert bb == 'x' as u8,
               1 => assert bb == 'y' as u8,
-              2 => assert bb == 'z' as u8
+              2 => assert bb == 'z' as u8,
+              _ => fail ~"test_bytes_iter failed"
             }
             i += 1;
         }
diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs
index b22fe2b9582..99e83d11e52 100644
--- a/src/libstd/base64.rs
+++ b/src/libstd/base64.rs
@@ -30,22 +30,25 @@ impl ~[u8]: to_base64 {
             i += 3u;
         }
 
-        match check len % 3u {
-          0u => (),
-          1u => {
+        // Heh, would be cool if we knew this was exhaustive
+        // (the dream of bounded integer types)
+        match len % 3 {
+          0 => (),
+          1 => {
             let n = (self[i] as uint) << 16u;
             str::push_char(s, chars[(n >> 18u) & 63u]);
             str::push_char(s, chars[(n >> 12u) & 63u]);
             str::push_char(s, '=');
             str::push_char(s, '=');
           }
-          2u => {
+          2 => {
             let n = (self[i] as uint) << 16u | (self[i + 1u] as uint) << 8u;
             str::push_char(s, chars[(n >> 18u) & 63u]);
             str::push_char(s, chars[(n >> 12u) & 63u]);
             str::push_char(s, chars[(n >> 6u) & 63u]);
             str::push_char(s, '=');
           }
+          _ => fail ~"Algebra is broken, please alert the math police"
         }
 
         s
diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs
index 5a587752093..b3222f7ab24 100644
--- a/src/libstd/ebml.rs
+++ b/src/libstd/ebml.rs
@@ -602,14 +602,17 @@ fn test_option_int() {
     fn deserialize_0<S: serialization::deserializer>(s: S) -> option<int> {
         do s.read_enum(~"core::option::t") {
             do s.read_enum_variant |i| {
-                match check i {
-                  0u => none,
-                  1u => {
+                match i {
+                  0 => none,
+                  1 => {
                     let v0 = do s.read_enum_variant_arg(0u) {
                         deserialize_1(s)
                     };
                     some(v0)
                   }
+                  _ => {
+                    fail #fmt("deserialize_0: unexpected variant %u", i);
+                  }
                 }
             }
         }
diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs
index 04a04691077..1c92fd4ce0d 100644
--- a/src/libstd/getopts.rs
+++ b/src/libstd/getopts.rs
@@ -431,11 +431,12 @@ mod tests {
         let args = ~[~"--test=20"];
         let opts = ~[reqopt(~"test")];
         let rs = getopts(args, opts);
-        match check rs {
+        match rs {
           ok(m) => {
             assert (opt_present(m, ~"test"));
             assert (opt_str(m, ~"test") == ~"20");
           }
+          _ => { fail ~"test_reqopt_long failed"; }
         }
     }
 
diff --git a/src/libstd/list.rs b/src/libstd/list.rs
index 4b8b75d3d66..0eb01aa5b66 100644
--- a/src/libstd/list.rs
+++ b/src/libstd/list.rs
@@ -91,7 +91,11 @@ pure fn tail<T: copy>(ls: @list<T>) -> @list<T> {
 
 /// Returns the first element of a list
 pure fn head<T: copy>(ls: @list<T>) -> T {
-    match check *ls { cons(hd, _) => hd }
+    match *ls {
+      cons(hd, _) => hd,
+      // makes me sad
+      _ => fail ~"head invoked on empty list"
+    }
 }
 
 /// Appends one list to another
diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs
index c27081a457b..15eb565dc84 100644
--- a/src/libstd/serialization.rs
+++ b/src/libstd/serialization.rs
@@ -260,9 +260,10 @@ fn deserialize_option<D: deserializer,T: copy>(d: D, st: fn() -> T)
     -> option<T> {
     do d.read_enum(~"option") {
         do d.read_enum_variant |i| {
-            match check i {
-              0u => none,
-              1u => some(d.read_enum_variant_arg(0u, || st() ))
+            match i {
+              0 => none,
+              1 => some(d.read_enum_variant_arg(0u, || st() )),
+              _ => fail(#fmt("Bad variant for option: %u", i))
             }
         }
     }
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index 47dbff2ccb1..1aa6c4d74da 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -572,26 +572,30 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
 fn strftime(format: ~str, tm: tm) -> ~str {
     fn parse_type(ch: char, tm: tm) -> ~str {
         //FIXME (#2350): Implement missing types.
-        match check ch {
-          'A' => match check tm.tm_wday as int {
+      let die = || #fmt("strftime: can't understand this format %c ",
+                             ch);
+        match ch {
+          'A' => match tm.tm_wday as int {
             0 => ~"Sunday",
             1 => ~"Monday",
             2 => ~"Tuesday",
             3 => ~"Wednesday",
             4 => ~"Thursday",
             5 => ~"Friday",
-            6 => ~"Saturday"
+            6 => ~"Saturday",
+            _ => die()
           },
-          'a' => match check tm.tm_wday as int {
+         'a' => match tm.tm_wday as int {
             0 => ~"Sun",
             1 => ~"Mon",
             2 => ~"Tue",
             3 => ~"Wed",
             4 => ~"Thu",
             5 => ~"Fri",
-            6 => ~"Sat"
+            6 => ~"Sat",
+            _ => die()
           },
-          'B' => match check tm.tm_mon as int {
+          'B' => match tm.tm_mon as int {
             0 => ~"January",
             1 => ~"February",
             2 => ~"March",
@@ -603,9 +607,10 @@ fn strftime(format: ~str, tm: tm) -> ~str {
             8 => ~"September",
             9 => ~"October",
             10 => ~"November",
-            11 => ~"December"
+            11 => ~"December",
+            _ => die()
           },
-          'b' | 'h' => match check tm.tm_mon as int {
+          'b' | 'h' => match tm.tm_mon as int {
             0 => ~"Jan",
             1 => ~"Feb",
             2 => ~"Mar",
@@ -618,6 +623,7 @@ fn strftime(format: ~str, tm: tm) -> ~str {
             9 => ~"Oct",
             10 => ~"Nov",
             11 => ~"Dec",
+            _  => die()
           },
           'C' => fmt!{"%02d", (tm.tm_year as int + 1900) / 100},
           'c' => {
@@ -712,7 +718,8 @@ fn strftime(format: ~str, tm: tm) -> ~str {
             fmt!{"%c%02d%02d", sign, h as int, m as int}
           }
           //'+' {}
-          '%' => ~"%"
+          '%' => ~"%",
+          _   => die()
         }
     }