Add CopyForDeref to custom MIR
This commit is contained in:
parent
0bcfd2d96e
commit
c3ab4f28d3
4 changed files with 30 additions and 0 deletions
|
@ -0,0 +1,12 @@
|
|||
// MIR for `copy_for_deref` after built
|
||||
|
||||
fn copy_for_deref(_1: (&i32, i32)) -> i32 {
|
||||
let mut _0: i32; // return place in scope 0 at $DIR/projections.rs:+0:38: +0:41
|
||||
let mut _2: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
|
||||
|
||||
bb0: {
|
||||
_2 = deref_copy (_1.0: &i32); // scope 0 at $DIR/projections.rs:+4:13: +4:37
|
||||
_0 = (*_2); // scope 0 at $DIR/projections.rs:+5:13: +5:24
|
||||
return; // scope 0 at $DIR/projections.rs:+6:13: +6:21
|
||||
}
|
||||
}
|
|
@ -71,6 +71,19 @@ fn simple_index(a: [i32; 10], b: &[i32]) -> i32 {
|
|||
})
|
||||
}
|
||||
|
||||
// EMIT_MIR projections.copy_for_deref.built.after.mir
|
||||
#[custom_mir(dialect = "runtime", phase = "initial")]
|
||||
fn copy_for_deref(x: (&i32, i32)) -> i32 {
|
||||
mir!(
|
||||
let temp: &i32;
|
||||
{
|
||||
temp = CopyForDeref(x.0);
|
||||
RET = *temp;
|
||||
Return()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(unions(U { a: 5 }), 5);
|
||||
assert_eq!(tuples((5, 6)), (5, 6));
|
||||
|
@ -82,4 +95,7 @@ fn main() {
|
|||
assert_eq!(o, Some(10));
|
||||
|
||||
assert_eq!(simple_index([0; 10], &[0; 10]), 0);
|
||||
|
||||
let one = 1;
|
||||
assert_eq!(copy_for_deref((&one, one)), 1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue