User type annotations can result in different mir-opt test results in CI vs locally (original) (raw)

In #73442, a mir-opt test that I blessed locally was failing on CI and I could not reproduce the failure locally - this was due to the DefId in the user type annotations of the test shown below, which appeared to be different locally versus on CI.

// compile-flags: -Z mir-opt-level=1 // Regression test for #72181, this ICE requires -Z mir-opt-level=1 flags.

use std::mem;

#[derive(Copy, Clone)] enum Never {}

union Foo { a: u64, b: Never }

// EMIT_MIR rustc.foo.mir_map.0.mir fn foo(xs: [(Never, u32); 1]) -> u32 { xs[0].1 }

// EMIT_MIR rustc.bar.mir_map.0.mir fn bar([(_, x)]: [(Never, u32); 1]) -> u32 { x }

// EMIT_MIR rustc.main.mir_map.0.mir fn main() { println!("{}", mem::size_of::());

let f = [Foo { a: 42 }, Foo { a: 10 }];
println!("{:?}", unsafe { f[0].a });

}

You can find my config.toml here and I was running tests with ./x.py test src/test/mir-opt --stage 1 (though I couldn't reproduce with a stage2 build either).

cc @rust-lang/wg-mir-opt