fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.2 KiB32 linesraw
1   LL|       |#![allow(unused_assignments)]
2   LL|       |// failure-status: 101
3   LL|       |
4   LL|      4|fn might_panic(should_panic: bool) {
5   LL|      4|    if should_panic {
6   LL|      1|        println!("panicking...");
7   LL|      1|        panic!("panics");
8   LL|      3|    } else {
9   LL|      3|        println!("Don't Panic");
10   LL|      3|    }
11   LL|      3|}
12   LL|       |
13   LL|      1|fn main() -> Result<(), u8> {
14   LL|      1|    let mut countdown = 10;
15   LL|     11|    while countdown > 0 {
16   LL|     11|        if countdown == 1 {
17   LL|      1|            might_panic(true);
18   LL|     10|        } else if countdown < 5 {
19   LL|      3|            might_panic(false);
20   LL|      6|        }
21   LL|     10|        countdown -= 1;
22   LL|       |    }
23   LL|      0|    Ok(())
24   LL|      0|}
25   LL|       |
26   LL|       |// Notes:
27   LL|       |//   1. Compare this program and its coverage results to those of the similar tests `abort.rs` and
28   LL|       |//      `try_error_result.rs`.
29   LL|       |//   2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the
30   LL|       |//      normal program exit cleanup, including writing out the current values of the coverage
31   LL|       |//      counters.
32