2024-07-27 01:36:17 -05:00
|
|
|
//@ test-mir-pass: InstSimplify-after-simplifycfg
|
2024-05-31 00:05:30 -05:00
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
// For each of these, only 2 of the 6 should simplify,
|
|
|
|
// as the others have the wrong types.
|
|
|
|
|
2024-07-27 01:36:17 -05:00
|
|
|
// EMIT_MIR ref_of_deref.references.InstSimplify-after-simplifycfg.diff
|
2024-05-31 00:05:30 -05:00
|
|
|
// CHECK-LABEL: references
|
|
|
|
pub fn references(const_ref: &i32, mut_ref: &mut [i32]) {
|
2024-08-18 17:51:53 -05:00
|
|
|
// CHECK: _3 = copy _1;
|
2024-05-31 00:05:30 -05:00
|
|
|
let _a = &*const_ref;
|
|
|
|
// CHECK: _4 = &(*_2);
|
|
|
|
let _b = &*mut_ref;
|
2024-08-18 17:51:53 -05:00
|
|
|
// CHECK: _5 = copy _2;
|
2024-05-31 00:05:30 -05:00
|
|
|
let _c = &mut *mut_ref;
|
|
|
|
// CHECK: _6 = &raw const (*_1);
|
|
|
|
let _d = &raw const *const_ref;
|
|
|
|
// CHECK: _7 = &raw const (*_2);
|
|
|
|
let _e = &raw const *mut_ref;
|
|
|
|
// CHECK: _8 = &raw mut (*_2);
|
|
|
|
let _f = &raw mut *mut_ref;
|
|
|
|
}
|
|
|
|
|
2024-07-27 01:36:17 -05:00
|
|
|
// EMIT_MIR ref_of_deref.pointers.InstSimplify-after-simplifycfg.diff
|
2024-05-31 00:05:30 -05:00
|
|
|
// CHECK-LABEL: pointers
|
|
|
|
pub unsafe fn pointers(const_ptr: *const [i32], mut_ptr: *mut i32) {
|
|
|
|
// CHECK: _3 = &(*_1);
|
|
|
|
let _a = &*const_ptr;
|
|
|
|
// CHECK: _4 = &(*_2);
|
|
|
|
let _b = &*mut_ptr;
|
|
|
|
// CHECK: _5 = &mut (*_2);
|
|
|
|
let _c = &mut *mut_ptr;
|
2024-08-18 17:51:53 -05:00
|
|
|
// CHECK: _6 = copy _1;
|
2024-05-31 00:05:30 -05:00
|
|
|
let _d = &raw const *const_ptr;
|
|
|
|
// CHECK: _7 = &raw const (*_2);
|
|
|
|
let _e = &raw const *mut_ptr;
|
2024-08-18 17:51:53 -05:00
|
|
|
// CHECK: _8 = copy _2;
|
2024-05-31 00:05:30 -05:00
|
|
|
let _f = &raw mut *mut_ptr;
|
|
|
|
}
|