]>
Commit | Line | Data |
---|---|---|
fc512014 | 1 | #![allow(unused_assignments, unused_variables, while_true)] |
29967ef6 | 2 | |
cdc7bbd5 XL |
3 | // This test confirms that (1) unexecuted infinite loops are handled correctly by the |
4 | // InstrumentCoverage MIR pass; and (2) Counter Expressions that subtract from zero can be dropped. | |
29967ef6 XL |
5 | |
6 | struct DebugTest; | |
7 | ||
8 | impl std::fmt::Debug for DebugTest { | |
9 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | |
10 | if true { | |
11 | if false { | |
12 | while true { | |
13 | } | |
14 | } | |
17df50a5 | 15 | write!(f, "cool")?; |
29967ef6 XL |
16 | } else { |
17 | } | |
cdc7bbd5 XL |
18 | |
19 | for i in 0..10 { | |
20 | if true { | |
21 | if false { | |
22 | while true {} | |
23 | } | |
17df50a5 | 24 | write!(f, "cool")?; |
cdc7bbd5 XL |
25 | } else { |
26 | } | |
27 | } | |
28 | Ok(()) | |
29 | } | |
30 | } | |
31 | ||
32 | struct DisplayTest; | |
33 | ||
34 | impl std::fmt::Display for DisplayTest { | |
35 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | |
36 | if false { | |
37 | } else { | |
38 | if false { | |
39 | while true {} | |
40 | } | |
17df50a5 | 41 | write!(f, "cool")?; |
cdc7bbd5 XL |
42 | } |
43 | for i in 0..10 { | |
44 | if false { | |
45 | } else { | |
46 | if false { | |
47 | while true {} | |
48 | } | |
17df50a5 | 49 | write!(f, "cool")?; |
cdc7bbd5 XL |
50 | } |
51 | } | |
29967ef6 XL |
52 | Ok(()) |
53 | } | |
54 | } | |
55 | ||
56 | fn main() { | |
57 | let debug_test = DebugTest; | |
58 | println!("{:?}", debug_test); | |
cdc7bbd5 XL |
59 | let display_test = DisplayTest; |
60 | println!("{}", display_test); | |
29967ef6 | 61 | } |