File: issue_81605.rs

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 (20 lines) | stat: -rw-r--r-- 674 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
//@ test-mir-pass: DataflowConstProp

// EMIT_MIR issue_81605.f.DataflowConstProp.diff

// Plese find the original issue [here](https://github.com/rust-lang/rust/issues/81605).
// This test program comes directly from the issue. Prior to this issue,
// the compiler cannot simplify the return value of `f` into 2. This was
// solved by adding a new MIR constant propagation based on dataflow
// analysis in [#101168](https://github.com/rust-lang/rust/pull/101168).

// CHECK-LABEL: fn f(
fn f() -> usize {
    // CHECK: switchInt(const true) -> [0: {{bb.*}}, otherwise: {{bb.*}}];
    1 + if true { 1 } else { 2 }
    // CHECK: _0 = const 2_usize;
}

fn main() {
    f();
}