File: aggregate.rs

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,245,360 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (29 lines) | stat: -rw-r--r-- 783 bytes parent folder | download
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
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//@ unit-test: GVN
//@ compile-flags: -O

// EMIT_MIR aggregate.main.GVN.diff
fn main() {
    // CHECK-LABEL: fn main(
    // CHECK: debug x => [[x:_.*]];
    // CHECK-NOT: = Add(
    // CHECK: [[x]] = const 1_u8;
    // CHECK-NOT: = Add(
    // CHECK: foo(const 1_u8)
    let x = (0, 1, 2).1 + 0;
    foo(x);
}

// Verify that we still propagate if part of the aggregate is not known.
// EMIT_MIR aggregate.foo.GVN.diff
fn foo(x: u8) {
    // CHECK-LABEL: fn foo(
    // CHECK: debug first => [[first:_.*]];
    // CHECK: debug second => [[second:_.*]];
    // CHECK-NOT: = Add(
    // CHECK: [[first]] = const 1_i32;
    // CHECK-NOT: = Add(
    // CHECK: [[second]] = const 3_i32;
    let first = (0, x).0 + 1;
    let second = (x, 1).1 + 2;
}