about summary refs log tree commit diff
path: root/src/test/run-make-fulldeps/coverage/try_error_result.rs
blob: 13c455172dd11554563ecc4ec755c6e339b2000c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#![allow(unused_assignments)]
// expect-exit-status-1

fn call(return_error: bool) -> Result<(),()> {
    if return_error {
        Err(())
    } else {
        Ok(())
    }
}

fn main() -> Result<(),()> {
    let mut
        countdown = 10
    ;
    for
        _
    in
        0..10
    {
        countdown
            -= 1
        ;
        if
            countdown < 5
        {
            call(/*return_error=*/ true)?;
            call(/*return_error=*/ false)?;
        }
        else
        {
            call(/*return_error=*/ false)?;
        }
    }
    Ok(())
}