mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
69 lines
2.5 KiB
Plaintext
69 lines
2.5 KiB
Plaintext
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| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
10| 1| if true {
|
|
11| 1| if false {
|
|
12| 0| while true {
|
|
13| 0| }
|
|
14| 1| }
|
|
15| 1| write!(f, "cool")?;
|
|
^0
|
|
16| 0| } else {
|
|
17| 0| }
|
|
18| |
|
|
19| 11| for i in 0..10 {
|
|
^10
|
|
20| 10| if true {
|
|
21| 10| if false {
|
|
22| 0| while true {}
|
|
23| 10| }
|
|
24| 10| write!(f, "cool")?;
|
|
^0
|
|
25| 0| } else {
|
|
26| 0| }
|
|
27| | }
|
|
28| 1| Ok(())
|
|
29| 1| }
|
|
30| |}
|
|
31| |
|
|
32| |struct DisplayTest;
|
|
33| |
|
|
34| |impl std::fmt::Display for DisplayTest {
|
|
35| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
36| 1| if false {
|
|
37| 0| } else {
|
|
38| 1| if false {
|
|
39| 0| while true {}
|
|
40| 1| }
|
|
41| 1| write!(f, "cool")?;
|
|
^0
|
|
42| | }
|
|
43| 11| for i in 0..10 {
|
|
^10
|
|
44| 10| if false {
|
|
45| 0| } else {
|
|
46| 10| if false {
|
|
47| 0| while true {}
|
|
48| 10| }
|
|
49| 10| write!(f, "cool")?;
|
|
^0
|
|
50| | }
|
|
51| | }
|
|
52| 1| Ok(())
|
|
53| 1| }
|
|
54| |}
|
|
55| |
|
|
56| 1|fn main() {
|
|
57| 1| let debug_test = DebugTest;
|
|
58| 1| println!("{:?}", debug_test);
|
|
59| 1| let display_test = DisplayTest;
|
|
60| 1| println!("{}", display_test);
|
|
61| 1|}
|
|
|