]> git.lizzy.rs Git - rust.git/blob - tests/run-make/coverage-reports/expected_show_coverage.closure.txt
Rollup merge of #106714 - Ezrashaw:remove-e0490, r=davidtwco
[rust.git] / tests / run-make / coverage-reports / expected_show_coverage.closure.txt
1     1|       |#![allow(unused_assignments, unused_variables)]
2     2|       |// compile-flags: -C opt-level=2 # fix described in rustc_middle/mir/mono.rs
3     3|      1|fn main() {
4     4|      1|    // Initialize test constants in a way that cannot be determined at compile time, to ensure
5     5|      1|    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
6     6|      1|    // dependent conditions.
7     7|      1|    let is_true = std::env::args().len() == 1;
8     8|      1|    let is_false = ! is_true;
9     9|      1|
10    10|      1|    let mut some_string = Some(String::from("the string content"));
11    11|      1|    println!(
12    12|      1|        "The string or alt: {}"
13    13|      1|        ,
14    14|      1|        some_string
15    15|      1|            .
16    16|      1|            unwrap_or_else
17    17|      1|        (
18    18|      1|            ||
19    19|      0|            {
20    20|      0|                let mut countdown = 0;
21    21|      0|                if is_false {
22    22|      0|                    countdown = 10;
23    23|      0|                }
24    24|      0|                "alt string 1".to_owned()
25    25|      1|            }
26    26|      1|        )
27    27|      1|    );
28    28|      1|
29    29|      1|    some_string = Some(String::from("the string content"));
30    30|      1|    let
31    31|      1|        a
32    32|      1|    =
33    33|      1|        ||
34    34|      0|    {
35    35|      0|        let mut countdown = 0;
36    36|      0|        if is_false {
37    37|      0|            countdown = 10;
38    38|      0|        }
39    39|      0|        "alt string 2".to_owned()
40    40|      0|    };
41    41|      1|    println!(
42    42|      1|        "The string or alt: {}"
43    43|      1|        ,
44    44|      1|        some_string
45    45|      1|            .
46    46|      1|            unwrap_or_else
47    47|      1|        (
48    48|      1|            a
49    49|      1|        )
50    50|      1|    );
51    51|      1|
52    52|      1|    some_string = None;
53    53|      1|    println!(
54    54|      1|        "The string or alt: {}"
55    55|      1|        ,
56    56|      1|        some_string
57    57|      1|            .
58    58|      1|            unwrap_or_else
59    59|      1|        (
60    60|      1|            ||
61    61|      1|            {
62    62|      1|                let mut countdown = 0;
63    63|      1|                if is_false {
64    64|      0|                    countdown = 10;
65    65|      1|                }
66    66|      1|                "alt string 3".to_owned()
67    67|      1|            }
68    68|      1|        )
69    69|      1|    );
70    70|      1|
71    71|      1|    some_string = None;
72    72|      1|    let
73    73|      1|        a
74    74|      1|    =
75    75|      1|        ||
76    76|      1|    {
77    77|      1|        let mut countdown = 0;
78    78|      1|        if is_false {
79    79|      0|            countdown = 10;
80    80|      1|        }
81    81|      1|        "alt string 4".to_owned()
82    82|      1|    };
83    83|      1|    println!(
84    84|      1|        "The string or alt: {}"
85    85|      1|        ,
86    86|      1|        some_string
87    87|      1|            .
88    88|      1|            unwrap_or_else
89    89|      1|        (
90    90|      1|            a
91    91|      1|        )
92    92|      1|    );
93    93|      1|
94    94|      1|    let
95    95|      1|        quote_closure
96    96|      1|    =
97    97|      1|        |val|
98    98|      5|    {
99    99|      5|        let mut countdown = 0;
100   100|      5|        if is_false {
101   101|      0|            countdown = 10;
102   102|      5|        }
103   103|      5|        format!("'{}'", val)
104   104|      5|    };
105   105|      1|    println!(
106   106|      1|        "Repeated, quoted string: {:?}"
107   107|      1|        ,
108   108|      1|        std::iter::repeat("repeat me")
109   109|      1|            .take(5)
110   110|      1|            .map
111   111|      1|        (
112   112|      1|            quote_closure
113   113|      1|        )
114   114|      1|            .collect::<Vec<_>>()
115   115|      1|    );
116   116|      1|
117   117|      1|    let
118   118|      1|        _unused_closure
119   119|       |    =
120   120|       |        |
121   121|       |            mut countdown
122   122|       |        |
123   123|      0|    {
124   124|      0|        if is_false {
125   125|      0|            countdown = 10;
126   126|      0|        }
127   127|      0|        "closure should be unused".to_owned()
128   128|      0|    };
129   129|       |
130   130|      1|    let mut countdown = 10;
131   131|      1|    let _short_unused_closure = | _unused_arg: u8 | countdown += 1;
132                                                                   ^0
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|       |
144   141|      1|    let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") };
145                                                                         ^0
146   142|       |
147   143|      1|    let _shortish_unused_closure = | _unused_arg: u8 | {
148   144|      0|        println!("not called")
149   145|      0|    };
150   146|       |
151   147|      1|    let _as_short_unused_closure = |
152   148|       |        _unused_arg: u8
153   149|      0|    | { println!("not called") };
154   150|       |
155   151|      1|    let _almost_as_short_unused_closure = |
156   152|       |        _unused_arg: u8
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|       |        | _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|}
222