about summary refs log tree commit diff
path: root/src/libstd
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 /src/libstd
parentb0f289397ce47ed8c4d4f97d94408e83a59abd5a (diff)
downloadrust-51d98d9c7bcdfad2daec697739b25193adc09ced.tar.gz
rust-51d98d9c7bcdfad2daec697739b25193adc09ced.zip
Expunge match checks
Diffstat (limited to 'src/libstd')
-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
6 files changed, 40 insertions, 21 deletions
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()
         }
     }