summaryrefslogtreecommitdiffstats
path: root/src/test/ui/try-block/issue-45124.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/try-block/issue-45124.rs')
-rw-r--r--src/test/ui/try-block/issue-45124.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/try-block/issue-45124.rs b/src/test/ui/try-block/issue-45124.rs
new file mode 100644
index 000000000..942014c91
--- /dev/null
+++ b/src/test/ui/try-block/issue-45124.rs
@@ -0,0 +1,18 @@
+// run-pass
+#![allow(unreachable_code)]
+// compile-flags: --edition 2018
+
+#![feature(try_blocks)]
+
+fn main() {
+ let mut a = 0;
+ let () = {
+ let _: Result<(), ()> = try {
+ let _ = Err(())?;
+ return
+ };
+ a += 1;
+ };
+ a += 2;
+ assert_eq!(a, 3);
+}