diff options
Diffstat (limited to 'tests/ui/try-block/try-block-type-error.rs')
-rw-r--r-- | tests/ui/try-block/try-block-type-error.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/try-block/try-block-type-error.rs b/tests/ui/try-block/try-block-type-error.rs new file mode 100644 index 000000000..fe1993a37 --- /dev/null +++ b/tests/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 +} |