diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-04-16 15:50:32 +0900 |
|---|---|---|
| committer | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-05-06 14:02:55 +0900 |
| commit | e69748ba4f48efdc9a1dfcf8c16bc9aba39a86e3 (patch) | |
| tree | 33fc77d7a08037da5deeb878068f5af0284aa732 /src/test/ui/match | |
| parent | 43271a39adc26d29350d4830b594c6435472815e (diff) | |
Move tests from `test/run-fail` to UI
Diffstat (limited to 'src/test/ui/match')
| -rw-r--r-- | src/test/ui/match/expr-match-panic-fn.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/match/expr-match-panic.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/match/match-bot-panic.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/match/match-disc-bot.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/match/match-wildcards.rs | 20 |
5 files changed, 77 insertions, 0 deletions
diff --git a/src/test/ui/match/expr-match-panic-fn.rs b/src/test/ui/match/expr-match-panic-fn.rs new file mode 100644 index 00000000000..c5bd7382f9f --- /dev/null +++ b/src/test/ui/match/expr-match-panic-fn.rs @@ -0,0 +1,18 @@ +// run-fail +// error-pattern:explicit panic + +fn f() -> ! { + panic!() +} + +fn g() -> isize { + let x = match true { + true => f(), + false => 10, + }; + return x; +} + +fn main() { + g(); +} diff --git a/src/test/ui/match/expr-match-panic.rs b/src/test/ui/match/expr-match-panic.rs new file mode 100644 index 00000000000..76144314fad --- /dev/null +++ b/src/test/ui/match/expr-match-panic.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:explicit panic + +fn main() { + let _x = match true { + false => 0, + true => panic!(), + }; +} diff --git a/src/test/ui/match/match-bot-panic.rs b/src/test/ui/match/match-bot-panic.rs new file mode 100644 index 00000000000..8b147cb5ab6 --- /dev/null +++ b/src/test/ui/match/match-bot-panic.rs @@ -0,0 +1,15 @@ +// run-fail +// error-pattern:explicit panic + +#![allow(unreachable_code)] +#![allow(unused_variables)] + +fn foo(s: String) {} + +fn main() { + let i = match Some::<isize>(3) { + None::<isize> => panic!(), + Some::<isize>(_) => panic!(), + }; + foo(i); +} diff --git a/src/test/ui/match/match-disc-bot.rs b/src/test/ui/match/match-disc-bot.rs new file mode 100644 index 00000000000..785237b34af --- /dev/null +++ b/src/test/ui/match/match-disc-bot.rs @@ -0,0 +1,15 @@ +// run-fail +// error-pattern:quux + +fn f() -> ! { + panic!("quux") +} +fn g() -> isize { + match f() { + true => 1, + false => 0, + } +} +fn main() { + g(); +} diff --git a/src/test/ui/match/match-wildcards.rs b/src/test/ui/match/match-wildcards.rs new file mode 100644 index 00000000000..b79fd03c133 --- /dev/null +++ b/src/test/ui/match/match-wildcards.rs @@ -0,0 +1,20 @@ +// run-fail +// error-pattern:squirrelcupcake + +fn cmp() -> isize { + match (Some('a'), None::<char>) { + (Some(_), _) => { + panic!("squirrelcupcake"); + } + (_, Some(_)) => { + panic!(); + } + _ => { + panic!("wat"); + } + } +} + +fn main() { + println!("{}", cmp()); +} |
