From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/try-block/try-block-opt-init.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/ui/try-block/try-block-opt-init.rs (limited to 'tests/ui/try-block/try-block-opt-init.rs') diff --git a/tests/ui/try-block/try-block-opt-init.rs b/tests/ui/try-block/try-block-opt-init.rs new file mode 100644 index 000000000..f4f45abcc --- /dev/null +++ b/tests/ui/try-block/try-block-opt-init.rs @@ -0,0 +1,16 @@ +// compile-flags: --edition 2018 + +#![feature(try_blocks)] + +fn use_val(_x: T) {} + +pub fn main() { + let cfg_res; + let _: Result<(), ()> = try { + Err(())?; + cfg_res = 5; + Ok::<(), ()>(())?; + use_val(cfg_res); + }; + assert_eq!(cfg_res, 5); //~ ERROR E0381 +} -- cgit v1.2.3