From fba35e1a3c87892823d1f4d436b9f00a7864cf16 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 30 Jan 2012 21:00:57 -0800 Subject: Require alts to be exhaustive middle::check_alt does the work. Lots of changes to add default cases into alts that were previously inexhaustive. --- src/test/compile-fail/non-exhaustive-match-nested.rs | 13 +++++++++++++ src/test/compile-fail/non-exhaustive-match.rs | 5 +++++ src/test/run-fail/non-exhaustive-match.rs | 9 --------- src/test/run-pass/alt-path.rs | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 src/test/compile-fail/non-exhaustive-match-nested.rs create mode 100644 src/test/compile-fail/non-exhaustive-match.rs delete mode 100644 src/test/run-fail/non-exhaustive-match.rs (limited to 'src/test') 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/compile-fail/non-exhaustive-match.rs b/src/test/compile-fail/non-exhaustive-match.rs new file mode 100644 index 00000000000..7beb7f1b17d --- /dev/null +++ b/src/test/compile-fail/non-exhaustive-match.rs @@ -0,0 +1,5 @@ +// -*- rust -*- +// error-pattern: Non-exhaustive pattern +enum t { a, b, } + +fn main() { let x = a; alt x { b { } } } diff --git a/src/test/run-fail/non-exhaustive-match.rs b/src/test/run-fail/non-exhaustive-match.rs deleted file mode 100644 index c6127d178c8..00000000000 --- a/src/test/run-fail/non-exhaustive-match.rs +++ /dev/null @@ -1,9 +0,0 @@ - - - -// -*- rust -*- - -// error-pattern:non-exhaustive match failure -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() { } -- cgit 1.4.1-3-g733a5