summaryrefslogtreecommitdiffstats
path: root/src/test/run-make/coverage-reports/expected_show_coverage.closure.txt
blob: 09ad276aa45ae0c2e4a079aa8ee97a54ccf1a21e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
    1|       |#![allow(unused_assignments, unused_variables)]
    2|       |// compile-flags: -C opt-level=2 # fix described in rustc_middle/mir/mono.rs
    3|      1|fn main() {
    4|      1|    // Initialize test constants in a way that cannot be determined at compile time, to ensure
    5|      1|    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
    6|      1|    // dependent conditions.
    7|      1|    let is_true = std::env::args().len() == 1;
    8|      1|    let is_false = ! is_true;
    9|      1|
   10|      1|    let mut some_string = Some(String::from("the string content"));
   11|      1|    println!(
   12|      1|        "The string or alt: {}"
   13|      1|        ,
   14|      1|        some_string
   15|      1|            .
   16|      1|            unwrap_or_else
   17|      1|        (
   18|      1|            ||
   19|      0|            {
   20|      0|                let mut countdown = 0;
   21|      0|                if is_false {
   22|      0|                    countdown = 10;
   23|      0|                }
   24|      0|                "alt string 1".to_owned()
   25|      1|            }
   26|      1|        )
   27|      1|    );
   28|      1|
   29|      1|    some_string = Some(String::from("the string content"));
   30|      1|    let
   31|      1|        a
   32|      1|    =
   33|      1|        ||
   34|      0|    {
   35|      0|        let mut countdown = 0;
   36|      0|        if is_false {
   37|      0|            countdown = 10;
   38|      0|        }
   39|      0|        "alt string 2".to_owned()
   40|       |    };
   41|      1|    println!(
   42|      1|        "The string or alt: {}"
   43|      1|        ,
   44|      1|        some_string
   45|      1|            .
   46|      1|            unwrap_or_else
   47|      1|        (
   48|      1|            a
   49|      1|        )
   50|      1|    );
   51|      1|
   52|      1|    some_string = None;
   53|      1|    println!(
   54|      1|        "The string or alt: {}"
   55|      1|        ,
   56|      1|        some_string
   57|      1|            .
   58|      1|            unwrap_or_else
   59|      1|        (
   60|      1|            ||
   61|      1|            {
   62|      1|                let mut countdown = 0;
   63|      1|                if is_false {
   64|      0|                    countdown = 10;
   65|      1|                }
   66|      1|                "alt string 3".to_owned()
   67|      1|            }
   68|      1|        )
   69|      1|    );
   70|      1|
   71|      1|    some_string = None;
   72|      1|    let
   73|      1|        a
   74|      1|    =
   75|      1|        ||
   76|      1|    {
   77|      1|        let mut countdown = 0;
   78|      1|        if is_false {
   79|      0|            countdown = 10;
   80|      1|        }
   81|      1|        "alt string 4".to_owned()
   82|       |    };
   83|      1|    println!(
   84|      1|        "The string or alt: {}"
   85|      1|        ,
   86|      1|        some_string
   87|      1|            .
   88|      1|            unwrap_or_else
   89|      1|        (
   90|      1|            a
   91|      1|        )
   92|      1|    );
   93|      1|
   94|      1|    let
   95|      1|        quote_closure
   96|      1|    =
   97|      1|        |val|
   98|      5|    {
   99|      5|        let mut countdown = 0;
  100|      5|        if is_false {
  101|      0|            countdown = 10;
  102|      5|        }
  103|      5|        format!("'{}'", val)
  104|       |    };
  105|      1|    println!(
  106|      1|        "Repeated, quoted string: {:?}"
  107|      1|        ,
  108|      1|        std::iter::repeat("repeat me")
  109|      1|            .take(5)
  110|      1|            .map
  111|      1|        (
  112|      1|            quote_closure
  113|      1|        )
  114|      1|            .collect::<Vec<_>>()
  115|      1|    );
  116|      1|
  117|      1|    let
  118|      1|        _unused_closure
  119|       |    =
  120|       |        |
  121|       |            mut countdown
  122|       |        |
  123|      0|    {
  124|      0|        if is_false {
  125|      0|            countdown = 10;
  126|      0|        }
  127|      0|        "closure should be unused".to_owned()
  128|       |    };
  129|       |
  130|      1|    let mut countdown = 10;
  131|      1|    let _short_unused_closure = | _unused_arg: u8 | countdown += 1;
                                                                  ^0
  132|       |
  133|       |
  134|      1|    let short_used_covered_closure_macro = | used_arg: u8 | println!("called");
  135|      1|    let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called");
                                                                              ^0
  136|      1|    let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called");
                                                                        ^0
  137|       |
  138|       |
  139|       |
  140|       |
  141|      1|    let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") };
                                                                        ^0
  142|       |
  143|      1|    let _shortish_unused_closure = | _unused_arg: u8 | {
  144|      0|        println!("not called")
  145|      0|    };
  146|       |
  147|      1|    let _as_short_unused_closure = |
  148|       |        _unused_arg: u8
  149|      0|    | { println!("not called") };
  150|       |
  151|      1|    let _almost_as_short_unused_closure = |
  152|       |        _unused_arg: u8
  153|      0|    | { println!("not called") }
  154|       |    ;
  155|       |
  156|       |
  157|       |
  158|       |
  159|       |
  160|      1|    let _short_unused_closure_line_break_no_block = | _unused_arg: u8 |
  161|      0|println!("not called")
  162|       |    ;
  163|       |
  164|      1|    let _short_unused_closure_line_break_no_block2 =
  165|       |        | _unused_arg: u8 |
  166|      0|            println!(
  167|      0|                "not called"
  168|      0|            )
  169|       |    ;
  170|       |
  171|      1|    let short_used_not_covered_closure_line_break_no_block_embedded_branch =
  172|       |        | _unused_arg: u8 |
  173|      0|            println!(
  174|      0|                "not called: {}",
  175|      0|                if is_true { "check" } else { "me" }
  176|       |            )
  177|       |    ;
  178|       |
  179|      1|    let short_used_not_covered_closure_line_break_block_embedded_branch =
  180|      1|        | _unused_arg: u8 |
  181|      0|        {
  182|      0|            println!(
  183|      0|                "not called: {}",
  184|      0|                if is_true { "check" } else { "me" }
  185|       |            )
  186|       |        }
  187|       |    ;
  188|       |
  189|      1|    let short_used_covered_closure_line_break_no_block_embedded_branch =
  190|      1|        | _unused_arg: u8 |
  191|      1|            println!(
  192|      1|                "not called: {}",
  193|      1|                if is_true { "check" } else { "me" }
                                                            ^0
  194|       |            )
  195|       |    ;
  196|       |
  197|      1|    let short_used_covered_closure_line_break_block_embedded_branch =
  198|      1|        | _unused_arg: u8 |
  199|      1|        {
  200|      1|            println!(
  201|      1|                "not called: {}",
  202|      1|                if is_true { "check" } else { "me" }
                                                            ^0
  203|       |            )
  204|       |        }
  205|       |    ;
  206|       |
  207|      1|    if is_false {
  208|      0|        short_used_not_covered_closure_macro(0);
  209|      0|        short_used_not_covered_closure_line_break_no_block_embedded_branch(0);
  210|      0|        short_used_not_covered_closure_line_break_block_embedded_branch(0);
  211|      1|    }
  212|      1|    short_used_covered_closure_macro(0);
  213|      1|    short_used_covered_closure_line_break_no_block_embedded_branch(0);
  214|      1|    short_used_covered_closure_line_break_block_embedded_branch(0);
  215|      1|}