2023-10-16 17:36:39 +00:00
|
|
|
// skip-filecheck
|
2022-11-09 18:21:42 +01:00
|
|
|
// unit-test: DataflowConstProp
|
2023-09-09 16:47:17 +00:00
|
|
|
// EMIT_MIR_FOR_EACH_BIT_WIDTH
|
2022-11-09 18:21:42 +01:00
|
|
|
|
2023-05-13 14:19:31 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2022-11-09 18:21:42 +01:00
|
|
|
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)]
|
2023-10-24 15:16:51 +00:00
|
|
|
struct BigStruct(f32, Option<S>, &'static [f32]);
|
2023-05-13 12:30:40 +00:00
|
|
|
|
2022-11-09 18:21:42 +01: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-12 16:44:53 +00:00
|
|
|
|
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);
|
2022-11-09 18:21:42 +01:00
|
|
|
}
|