mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-25 23:14:12 +00:00
6885733c41
The test cases src/test/mir-opt/building/custom/consts.rs and src/test/mir-opt/const_prop/mutable_variable_no_prop.rs are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the MIR test files. Fix this by choosing constant values that have the same encoding on big- and little-endian platforms. The test case src/test/mir-opt/issues/issue_75439.rs is failing as well, but since the purpose of the test is to validate handling of big-endian integer encodings on a little-endian platform, it does not make much sense to run it on big-endian platforms in the first place - we can just ignore it there. Fixed part of https://github.com/rust-lang/rust/issues/105383.
37 lines
705 B
Rust
37 lines
705 B
Rust
#![feature(custom_mir, core_intrinsics, inline_const)]
|
|
|
|
extern crate core;
|
|
use core::intrinsics::mir::*;
|
|
|
|
const D: i32 = 5;
|
|
|
|
// EMIT_MIR consts.consts.built.after.mir
|
|
#[custom_mir(dialect = "built")]
|
|
fn consts<const C: u32>() {
|
|
mir!({
|
|
let _a = 5_u8;
|
|
let _b = const { 5_i8 };
|
|
let _c = C;
|
|
let _d = D;
|
|
let _e = consts::<10>;
|
|
Return()
|
|
})
|
|
}
|
|
|
|
static S: i32 = 0x05050505;
|
|
static mut T: i32 = 0x0a0a0a0a;
|
|
// EMIT_MIR consts.statics.built.after.mir
|
|
#[custom_mir(dialect = "built")]
|
|
fn statics() {
|
|
mir!({
|
|
let _a: &i32 = Static(S);
|
|
let _b: *mut i32 = StaticMut(T);
|
|
Return()
|
|
})
|
|
}
|
|
|
|
fn main() {
|
|
consts::<5>();
|
|
statics();
|
|
}
|