File: let_else_loop.coverage

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (31 lines) | stat: -rw-r--r-- 1,309 bytes parent folder | download | duplicates (3)
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
   LL|       |#![feature(coverage_attribute)]
   LL|       |//@ edition: 2021
   LL|       |
   LL|       |// Regression test for <https://github.com/rust-lang/rust/issues/122738>.
   LL|       |// These code patterns should not trigger an ICE when allocating a physical
   LL|       |// counter to a node and also one of its in-edges, because that is allowed
   LL|       |// when the node contains a tight loop to itself.
   LL|       |
   LL|      1|fn loopy(cond: bool) {
   LL|      1|    let true = cond else { loop {} };
                                         ^0
   LL|      1|}
   LL|       |
   LL|       |// Variant that also has `loop {}` on the success path.
   LL|       |// This isn't needed to catch the original ICE, but might help detect regressions.
   LL|      0|fn _loop_either_way(cond: bool) {
   LL|      0|    let true = cond else { loop {} };
   LL|      0|    loop {}
   LL|       |}
   LL|       |
   LL|       |// Variant using regular `if` instead of let-else.
   LL|       |// This doesn't trigger the original ICE, but might help detect regressions.
   LL|      0|fn _if(cond: bool) {
   LL|      0|    if cond { loop {} } else { loop {} }
   LL|       |}
   LL|       |
   LL|       |#[coverage(off)]
   LL|       |fn main() {
   LL|       |    loopy(true);
   LL|       |}