summaryrefslogtreecommitdiffstats
path: root/src/test/ui/try-block/try-block-type-error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/try-block/try-block-type-error.rs')
-rw-r--r--src/test/ui/try-block/try-block-type-error.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/try-block/try-block-type-error.rs b/src/test/ui/try-block/try-block-type-error.rs
new file mode 100644
index 000000000..fe1993a37
--- /dev/null
+++ b/src/test/ui/try-block/try-block-type-error.rs
@@ -0,0 +1,18 @@
+// compile-flags: --edition 2018
+
+#![feature(try_blocks)]
+
+fn foo() -> Option<()> { Some(()) }
+
+fn main() {
+ let _: Option<f32> = try {
+ foo()?;
+ 42
+ //~^ ERROR type mismatch
+ };
+
+ let _: Option<i32> = try {
+ foo()?;
+ };
+ //~^ ERROR type mismatch
+}