diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-01-30 21:00:57 -0800 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-01-31 10:08:24 -0800 |
| commit | fba35e1a3c87892823d1f4d436b9f00a7864cf16 (patch) | |
| tree | 1fadaaee99ef266bd2f709fb2aa5577184ab611e /src/test | |
| parent | 813a55d89135efb716dd80e96453a091a7cfc631 (diff) | |
Require alts to be exhaustive
middle::check_alt does the work. Lots of changes to add default cases into alts that were previously inexhaustive.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/non-exhaustive-match-nested.rs | 13 | ||||
| -rw-r--r-- | src/test/compile-fail/non-exhaustive-match.rs (renamed from src/test/run-fail/non-exhaustive-match.rs) | 6 | ||||
| -rw-r--r-- | src/test/run-pass/alt-path.rs | 2 |
3 files changed, 15 insertions, 6 deletions
diff --git a/src/test/compile-fail/non-exhaustive-match-nested.rs b/src/test/compile-fail/non-exhaustive-match-nested.rs new file mode 100644 index 00000000000..b3b854f53e5 --- /dev/null +++ b/src/test/compile-fail/non-exhaustive-match-nested.rs @@ -0,0 +1,13 @@ +// -*- rust -*- +// error-pattern: Non-exhaustive pattern +enum t { a(u), b } +enum u { c, d } + +fn main() { + let x = a(c); + alt x { + a(d) { fail "hello"; } + b { fail "goodbye"; } + } +} + diff --git a/src/test/run-fail/non-exhaustive-match.rs b/src/test/compile-fail/non-exhaustive-match.rs index c6127d178c8..7beb7f1b17d 100644 --- a/src/test/run-fail/non-exhaustive-match.rs +++ b/src/test/compile-fail/non-exhaustive-match.rs @@ -1,9 +1,5 @@ - - - // -*- rust -*- - -// error-pattern:non-exhaustive match failure +// error-pattern: Non-exhaustive pattern enum t { a, b, } fn main() { let x = a; alt x { b { } } } diff --git a/src/test/run-pass/alt-path.rs b/src/test/run-pass/alt-path.rs index cd7497aeda4..aa3ccfcbafd 100644 --- a/src/test/run-pass/alt-path.rs +++ b/src/test/run-pass/alt-path.rs @@ -4,6 +4,6 @@ mod m1 { enum foo { foo1, foo2, } } -fn bar(x: m1::foo) { alt x { m1::foo1 { } } } +fn bar(x: m1::foo) { alt x { m1::foo1 { } m1::foo2 { } } } fn main() { } |
