Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.0 KiB
Rust
Raw Normal View History

// skip-filecheck
// unit-test: DataflowConstProp
2023-09-09 16:47:17 +00:00
// EMIT_MIR_FOR_EACH_BIT_WIDTH
2023-05-13 14:19:31 +00:00
#[derive(Copy, Clone)]
struct S(i32);
2023-05-13 14:19:31 +00:00
#[derive(Copy, Clone)]
2023-09-17 09:35:06 +00:00
struct SmallStruct(f32, Option<S>, &'static [f32]);
#[derive(Copy, Clone)]
struct BigStruct(f32, Option<S>, &'static [f32]);
2023-05-13 12:30:40 +00:00
// EMIT_MIR struct.main.DataflowConstProp.diff
fn main() {
let mut s = S(1);
let a = s.0 + 2;
s.0 = 3;
let b = a + s.0;
2023-05-13 12:30:40 +00:00
2023-09-17 09:35:06 +00:00
const SMALL_VAL: SmallStruct = SmallStruct(4., Some(S(1)), &[]);
let SmallStruct(a, b, c) = SMALL_VAL;
static SMALL_STAT: &SmallStruct = &SmallStruct(9., None, &[13.]);
let SmallStruct(a, b, c) = *SMALL_STAT;
let ss = SmallStruct(a, b, c);
const BIG_VAL: BigStruct = BigStruct(25., None, &[]);
let BigStruct(a, b, c) = BIG_VAL;
2023-05-13 14:19:31 +00:00
2023-09-17 09:35:06 +00:00
static BIG_STAT: &BigStruct = &BigStruct(82., Some(S(35)), &[45., 72.]);
let BigStruct(a, b, c) = *BIG_STAT;
2023-09-17 09:35:06 +00:00
// We arbitrarily limit the size of synthetized values to 4 pointers.
// `BigStruct` can be read, but we will keep a MIR aggregate for this.
let bs = BigStruct(a, b, c);
}