]> git.lizzy.rs Git - rust.git/blob - src/test/run-make/coverage/while_early_ret.rs
Auto merge of #98457 - japaric:gh98378, r=m-ou-se
[rust.git] / src / test / run-make / coverage / while_early_ret.rs
1 #![allow(unused_assignments)]
2 // expect-exit-status-1
3
4 fn main() -> Result<(),u8> {
5     let mut countdown = 10;
6     while
7         countdown
8             >
9         0
10     {
11         if
12             countdown
13                 <
14             5
15         {
16             return
17                 if
18                     countdown
19                         >
20                     8
21                 {
22                     Ok(())
23                 }
24                 else
25                 {
26                     Err(1)
27                 }
28                 ;
29         }
30         countdown
31             -=
32         1
33         ;
34     }
35     Ok(())
36 }
37
38 // ISSUE(77553): Originally, this test had `Err(1)` on line 22 (instead of `Ok(())`) and
39 // `std::process::exit(2)` on line 26 (instead of `Err(1)`); and this worked as expected on Linux
40 // and MacOS. But on Windows (MSVC, at least), the call to `std::process::exit()` exits the program
41 // without saving the InstrProf coverage counters. The use of `std::process:exit()` is not critical
42 // to the coverage test for early returns, but this is a limitation that should be fixed.