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