about summary refs log tree commit diff
path: root/src/test/ui/try-block
diff options
context:
space:
mode:
authorKampfkarren <boynedmaster@gmail.com>2019-04-10 10:35:48 -0700
committerKampfkarren <boynedmaster@gmail.com>2019-04-10 10:35:48 -0700
commit4a938b5b3c475a5a12fa582eca2dd91d76cb0d3e (patch)
treeed8e4bdc1fa1a9033961b4eaa2f9c6b85674ddb5 /src/test/ui/try-block
parent53b622a48a7945e223dbc5cfb30f7cbd38acc7c5 (diff)
downloadrust-4a938b5b3c475a5a12fa582eca2dd91d76cb0d3e.tar.gz
rust-4a938b5b3c475a5a12fa582eca2dd91d76cb0d3e.zip
Special error when using catch after try
Diffstat (limited to 'src/test/ui/try-block')
-rw-r--r--src/test/ui/try-block/try-block-catch.rs9
-rw-r--r--src/test/ui/try-block/try-block-catch.stderr10
2 files changed, 19 insertions, 0 deletions
diff --git a/src/test/ui/try-block/try-block-catch.rs b/src/test/ui/try-block/try-block-catch.rs
new file mode 100644
index 00000000000..8f3d6d87258
--- /dev/null
+++ b/src/test/ui/try-block/try-block-catch.rs
@@ -0,0 +1,9 @@
+// compile-flags: --edition 2018
+
+#![feature(try_blocks)]
+
+fn main() {
+	let res: Option<bool> = try {
+		true
+	} catch { }; //~ ERROR `try {} catch` is not a valid syntax
+}
diff --git a/src/test/ui/try-block/try-block-catch.stderr b/src/test/ui/try-block/try-block-catch.stderr
new file mode 100644
index 00000000000..0689647d3b2
--- /dev/null
+++ b/src/test/ui/try-block/try-block-catch.stderr
@@ -0,0 +1,10 @@
+error: `try {} catch` is not a valid syntax
+  --> $DIR/try-block-catch.rs:8:4
+   |
+LL |     } catch { }; //~ ERROR `try {} catch` is not a valid syntax
+   |       ^^^^^
+   |
+   = help: try using `match` on the result of the `try` block instead
+
+error: aborting due to previous error
+