|
37 | 37 | 37| 0| countdown = 10;
|
38 | 38 | 38| 0| }
|
39 | 39 | 39| 0| "alt string 2".to_owned()
|
40 |
| - 40| 1| }; |
| 40 | + 40| 0| }; |
41 | 41 | 41| 1| println!(
|
42 | 42 | 42| 1| "The string or alt: {}"
|
43 | 43 | 43| 1| ,
|
|
125 | 125 | 125| 0| countdown = 10;
|
126 | 126 | 126| 0| }
|
127 | 127 | 127| 0| "closure should be unused".to_owned()
|
128 |
| - 128| 1| }; |
129 |
| - 129| 1| |
| 128 | + 128| 0| }; |
| 129 | + 129| | |
130 | 130 | 130| 1| let mut countdown = 10;
|
131 | 131 | 131| 1| let _short_unused_closure = | _unused_arg: u8 | countdown += 1;
|
132 | 132 | ^0
|
133 |
| - 132| 1| |
134 |
| - 133| 1| // Macros can sometimes confuse the coverage results. Compare this next assignment, with an |
135 |
| - 134| 1| // unused closure that invokes the `println!()` macro, with the closure assignment above, that |
136 |
| - 135| 1| // does not use a macro. The closure above correctly shows `0` executions. |
137 |
| - 136| 1| let _short_unused_closure = | _unused_arg: u8 | println!("not called"); |
138 |
| - 137| 1| // The closure assignment above is executed, with a line count of `1`, but the `println!()` |
139 |
| - 138| 1| // could not have been called, and yet, there is no indication that it wasn't... |
140 |
| - 139| 1| |
141 |
| - 140| 1| // ...but adding block braces gives the expected result, showing the block was not executed. |
| 133 | + 132| | |
| 134 | + 133| | |
| 135 | + 134| 1| let short_used_covered_closure_macro = | used_arg: u8 | println!("called"); |
| 136 | + 135| 1| let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called"); |
| 137 | + ^0 |
| 138 | + 136| 1| let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called"); |
| 139 | + ^0 |
| 140 | + 137| | |
| 141 | + 138| | |
| 142 | + 139| | |
| 143 | + 140| | |
142 | 144 | 141| 1| let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") };
|
143 | 145 | ^0
|
144 |
| - 142| 1| |
| 146 | + 142| | |
145 | 147 | 143| 1| let _shortish_unused_closure = | _unused_arg: u8 | {
|
146 | 148 | 144| 0| println!("not called")
|
147 |
| - 145| 1| }; |
148 |
| - 146| 1| |
| 149 | + 145| 0| }; |
| 150 | + 146| | |
149 | 151 | 147| 1| let _as_short_unused_closure = |
|
150 | 152 | 148| | _unused_arg: u8
|
151 |
| - 149| 1| | { println!("not called") }; |
152 |
| - ^0 |
153 |
| - 150| 1| |
| 153 | + 149| 0| | { println!("not called") }; |
| 154 | + 150| | |
154 | 155 | 151| 1| let _almost_as_short_unused_closure = |
|
155 | 156 | 152| | _unused_arg: u8
|
156 |
| - 153| 1| | { println!("not called") } |
157 |
| - ^0 |
158 |
| - 154| 1| ; |
159 |
| - 155| 1|} |
| 157 | + 153| 0| | { println!("not called") } |
| 158 | + 154| | ; |
| 159 | + 155| | |
| 160 | + 156| | |
| 161 | + 157| | |
| 162 | + 158| | |
| 163 | + 159| | |
| 164 | + 160| 1| let _short_unused_closure_line_break_no_block = | _unused_arg: u8 | |
| 165 | + 161| 0|println!("not called") |
| 166 | + 162| | ; |
| 167 | + 163| | |
| 168 | + 164| 1| let _short_unused_closure_line_break_no_block2 = |
| 169 | + 165| | | _unused_arg: u8 | |
| 170 | + 166| 0| println!( |
| 171 | + 167| 0| "not called" |
| 172 | + 168| 0| ) |
| 173 | + 169| | ; |
| 174 | + 170| | |
| 175 | + 171| 1| let short_used_not_covered_closure_line_break_no_block_embedded_branch = |
| 176 | + 172| 1| | _unused_arg: u8 | |
| 177 | + 173| 0| println!( |
| 178 | + 174| 0| "not called: {}", |
| 179 | + 175| 0| if is_true { "check" } else { "me" } |
| 180 | + 176| 0| ) |
| 181 | + 177| | ; |
| 182 | + 178| | |
| 183 | + 179| 1| let short_used_not_covered_closure_line_break_block_embedded_branch = |
| 184 | + 180| 1| | _unused_arg: u8 | |
| 185 | + 181| 0| { |
| 186 | + 182| 0| println!( |
| 187 | + 183| 0| "not called: {}", |
| 188 | + 184| 0| if is_true { "check" } else { "me" } |
| 189 | + 185| | ) |
| 190 | + 186| 0| } |
| 191 | + 187| | ; |
| 192 | + 188| | |
| 193 | + 189| 1| let short_used_covered_closure_line_break_no_block_embedded_branch = |
| 194 | + 190| 1| | _unused_arg: u8 | |
| 195 | + 191| 1| println!( |
| 196 | + 192| 1| "not called: {}", |
| 197 | + 193| 1| if is_true { "check" } else { "me" } |
| 198 | + ^0 |
| 199 | + 194| 1| ) |
| 200 | + 195| | ; |
| 201 | + 196| | |
| 202 | + 197| 1| let short_used_covered_closure_line_break_block_embedded_branch = |
| 203 | + 198| 1| | _unused_arg: u8 | |
| 204 | + 199| 1| { |
| 205 | + 200| 1| println!( |
| 206 | + 201| 1| "not called: {}", |
| 207 | + 202| 1| if is_true { "check" } else { "me" } |
| 208 | + ^0 |
| 209 | + 203| | ) |
| 210 | + 204| 1| } |
| 211 | + 205| | ; |
| 212 | + 206| | |
| 213 | + 207| 1| if is_false { |
| 214 | + 208| 0| short_used_not_covered_closure_macro(0); |
| 215 | + 209| 0| short_used_not_covered_closure_line_break_no_block_embedded_branch(0); |
| 216 | + 210| 0| short_used_not_covered_closure_line_break_block_embedded_branch(0); |
| 217 | + 211| 1| } |
| 218 | + 212| 1| short_used_covered_closure_macro(0); |
| 219 | + 213| 1| short_used_covered_closure_line_break_no_block_embedded_branch(0); |
| 220 | + 214| 1| short_used_covered_closure_line_break_block_embedded_branch(0); |
| 221 | + 215| 1|} |
160 | 222 |
|
0 commit comments