about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-02-15 09:40:42 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-02-15 15:47:42 +0100
commit67cc89f38d2e75cb0dcd6303fbe4bb4f659277a7 (patch)
tree99caacd6c05c72beb28e73a9aa759b5db1d88114 /src/libcore
parent4b63826050dfc579b9ac65a6b72ad0ca6f6b51fc (diff)
downloadrust-67cc89f38d2e75cb0dcd6303fbe4bb4f659277a7.tar.gz
rust-67cc89f38d2e75cb0dcd6303fbe4bb4f659277a7.zip
Rewrite exhaustiveness checker
Issue #352
Closes #1720

The old checker would happily accept things like 'alt x { @some(a) { a } }'.
It now properly descends into patterns, checks exhaustiveness of booleans,
and complains when number/string patterns aren't exhaustive.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/bool.rs3
-rw-r--r--src/libcore/str.rs4
2 files changed, 4 insertions, 3 deletions
diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs
index d027e3825e1..cc4efe54dfc 100644
--- a/src/libcore/bool.rs
+++ b/src/libcore/bool.rs
@@ -60,9 +60,10 @@ pure fn is_false(v: t) -> bool { !v }
   brief = "Parse logic value from `s`"
 )]
 pure fn from_str(s: str) -> t {
-    alt s {
+    alt check s {
       "true" { true }
       "false" { false }
+      _ { fail "'" + s + "' is not a valid boolean string"; }
     }
 }
 
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index d71828c79e8..f79594a3023 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -2140,7 +2140,7 @@ mod tests {
     fn test_chars_iter() {
         let i = 0;
         chars_iter("x\u03c0y") {|ch|
-            alt i {
+            alt check i {
               0 { assert ch == 'x'; }
               1 { assert ch == '\u03c0'; }
               2 { assert ch == 'y'; }
@@ -2156,7 +2156,7 @@ mod tests {
         let i = 0;
 
         bytes_iter("xyz") {|bb|
-            alt i {
+            alt check i {
               0 { assert bb == 'x' as u8; }
               1 { assert bb == 'y' as u8; }
               2 { assert bb == 'z' as u8; }