]> git.proxmox.com Git - rustc.git/blob - src/test/run-make-fulldeps/coverage/loops_branches.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / run-make-fulldeps / coverage / loops_branches.rs
1 #![allow(unused_assignments, unused_variables, while_true)]
2
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.
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 }
15 write!(f, "cool")?;
16 } else {
17 }
18
19 for i in 0..10 {
20 if true {
21 if false {
22 while true {}
23 }
24 write!(f, "cool")?;
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 }
41 write!(f, "cool")?;
42 }
43 for i in 0..10 {
44 if false {
45 } else {
46 if false {
47 while true {}
48 }
49 write!(f, "cool")?;
50 }
51 }
52 Ok(())
53 }
54 }
55
56 fn main() {
57 let debug_test = DebugTest;
58 println!("{:?}", debug_test);
59 let display_test = DisplayTest;
60 println!("{}", display_test);
61 }