summaryrefslogtreecommitdiffstats
path: root/src/test/ui/try-block/try-block-opt-init.rs
blob: f4f45abcc75b1ad1037bdff3662cb203c8d67aac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// compile-flags: --edition 2018

#![feature(try_blocks)]

fn use_val<T: Sized>(_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
}