File: aggregate_copy.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 (43 lines) | stat: -rw-r--r-- 1,194 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
32
33
34
35
36
37
38
39
40
41
42
43
//! Verify that we manage to propagate the value of aggregate `a` even without directly mentioning
//! the contained scalars.
//@ test-mir-pass: DataflowConstProp
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes

const Foo: (u32, u32) = (5, 3);

fn foo() -> u32 {
    // CHECK-LABEL: fn foo(
    // CHECK: debug a => [[a:_.*]];
    // CHECK: debug b => [[b:_.*]];
    // CHECK: debug c => [[c:_.*]];

    // CHECK:bb0: {
    // CHECK:    [[a]] = const Foo;
    // CHECK:    [[b]] = const (5_u32, 3_u32);
    // CHECK:    [[c]] = const 3_u32;
    // CHECK:    {{_.*}} = const 3_u32;
    // CHECK:    {{_.*}} = const true;
    // CHECK:    switchInt(const true) -> [0: bb2, otherwise: bb1];

    // CHECK:bb1: {
    // CHECK:    _0 = const 5_u32;
    // CHECK:    goto -> bb3;

    // CHECK:bb2: {
    // CHECK:    _0 = const 13_u32;
    // CHECK:    goto -> bb3;

    let a = Foo;
    // This copies the struct in `a`. We want to ensure that we do track the contents of `a`
    // because we need to read `b` later.
    let b = a;
    let c = b.1;
    if c >= 2 { b.0 } else { 13 }
}

fn main() {
    // CHECK-LABEL: fn main(
    foo();
}

// EMIT_MIR aggregate_copy.foo.DataflowConstProp.diff