Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "copy" to Debug fmt for copy operands #122551

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ b2d2184edea578109a48ec3d8decbee5948e8f35
ec2cc761bc7067712ecc7734502f703fe3b024c8
# format use declarations
84ac80f1921afc243d71fd0caaa4f2838c294102
# bless mir-opt tests to add `copy`
99cb0c6bc399fb94a0ddde7e9b38e9c00d523bad
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ impl<'tcx> Debug for Operand<'tcx> {
use self::Operand::*;
match *self {
Constant(ref a) => write!(fmt, "{a:?}"),
Copy(ref place) => write!(fmt, "{place:?}"),
Copy(ref place) => write!(fmt, "copy {place:?}"),
Move(ref place) => write!(fmt, "move {place:?}"),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn address_of_reborrow() -> () {
StorageLive(_6);
_6 = &raw const (*_1);
AscribeUserType(_6, o, UserTypeProjection { base: UserType(0), projs: [] });
_5 = _6;
_5 = copy _6;
StorageDead(_6);
StorageDead(_5);
StorageLive(_7);
Expand All @@ -153,7 +153,7 @@ fn address_of_reborrow() -> () {
_9 = move _10 as *const dyn std::marker::Send (PointerCoercion(Unsize));
StorageDead(_10);
AscribeUserType(_9, o, UserTypeProjection { base: UserType(1), projs: [] });
_8 = _9;
_8 = copy _9;
StorageDead(_9);
StorageDead(_8);
StorageLive(_11);
Expand Down Expand Up @@ -194,7 +194,7 @@ fn address_of_reborrow() -> () {
StorageLive(_22);
_22 = &raw const (*_3);
AscribeUserType(_22, o, UserTypeProjection { base: UserType(10), projs: [] });
_21 = _22;
_21 = copy _22;
StorageDead(_22);
StorageDead(_21);
StorageLive(_23);
Expand All @@ -207,7 +207,7 @@ fn address_of_reborrow() -> () {
_25 = move _26 as *const dyn std::marker::Send (PointerCoercion(Unsize));
StorageDead(_26);
AscribeUserType(_25, o, UserTypeProjection { base: UserType(11), projs: [] });
_24 = _25;
_24 = copy _25;
StorageDead(_25);
StorageDead(_24);
StorageLive(_27);
Expand Down Expand Up @@ -242,7 +242,7 @@ fn address_of_reborrow() -> () {
StorageLive(_36);
_36 = &raw mut (*_3);
AscribeUserType(_36, o, UserTypeProjection { base: UserType(20), projs: [] });
_35 = _36;
_35 = copy _36;
StorageDead(_36);
StorageDead(_35);
StorageLive(_37);
Expand All @@ -255,7 +255,7 @@ fn address_of_reborrow() -> () {
_39 = move _40 as *mut dyn std::marker::Send (PointerCoercion(Unsize));
StorageDead(_40);
AscribeUserType(_39, o, UserTypeProjection { base: UserType(21), projs: [] });
_38 = _39;
_38 = copy _39;
StorageDead(_39);
StorageDead(_38);
StorageLive(_41);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ fn main() -> () {
StorageDead(_4);
StorageLive(_5);
StorageLive(_6);
_6 = _3;
_6 = copy _3;
_5 = foo(move _6) -> [return: bb1, unwind unreachable];
}

bb1: {
StorageDead(_6);
StorageLive(_7);
_7 = _2;
_7 = copy _2;
_8 = Len(_1);
_9 = Lt(_7, _8);
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> [success: bb2, unwind unreachable];
_9 = Lt(copy _7, copy _8);
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, copy _7) -> [success: bb2, unwind unreachable];
}

bb2: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ fn main() -> () {
StorageDead(_4);
StorageLive(_5);
StorageLive(_6);
_6 = _3;
_6 = copy _3;
_5 = foo(move _6) -> [return: bb1, unwind continue];
}

bb1: {
StorageDead(_6);
StorageLive(_7);
_7 = _2;
_7 = copy _2;
_8 = Len(_1);
_9 = Lt(_7, _8);
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> [success: bb2, unwind continue];
_9 = Lt(copy _7, copy _8);
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, copy _7) -> [success: bb2, unwind continue];
}

bb2: {
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/array_index_is_temporary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
// CHECK: debug x => [[x:_.*]];
// CHECK: debug y => [[y:_.*]];
// CHECK: [[y]] = const 1_usize;
// CHECK: [[tmp:_.*]] = [[y]];
// CHECK: [[tmp:_.*]] = copy [[y]];
// CHECK: [[x]][[[tmp]]] =
let mut x = [42, 43, 44];
let mut y = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ yields ()

bb0: {
StorageLive(_3);
_3 = (_1.0: i32);
_3 = copy (_1.0: i32);
FakeRead(ForLet(None), _3);
StorageLive(_4);
_4 = &_3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ yields ()

bb0: {
StorageLive(_3);
_3 = (_1.0: i32);
_3 = copy (_1.0: i32);
FakeRead(ForLet(None), _3);
StorageLive(_4);
_4 = &_3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ yields ()

bb0: {
StorageLive(_3);
_3 = (_1.0: i32);
_3 = copy (_1.0: i32);
FakeRead(ForLet(None), _3);
StorageLive(_4);
_4 = &_3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ yields ()

bb0: {
StorageLive(_3);
_3 = (_1.0: i32);
_3 = copy (_1.0: i32);
FakeRead(ForLet(None), _3);
StorageLive(_4);
_4 = &_3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main::{closure#0}::{closure#1}(_1: &{async closure@$DIR/async_closure_shims.r
let mut _0: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10};

bb0: {
_0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: ((*_1).0: &i32) };
_0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: copy ((*_1).0: &i32) };
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main::{closure#0}::{closure#1}(_1: &{async closure@$DIR/async_closure_shims.r
let mut _0: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10};

bb0: {
_0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: ((*_1).0: &i32) };
_0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: copy ((*_1).0: &i32) };
return;
}
}
2 changes: 1 addition & 1 deletion tests/mir-opt/basic_assignment.main.ElaborateDrops.diff
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
_1 = const false;
StorageLive(_2);
StorageLive(_3);
_3 = _1;
_3 = copy _1;
_2 = move _3;
StorageDead(_3);
StorageLive(_4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() -> () {
FakeRead(ForLet(None), _1);
StorageLive(_2);
StorageLive(_3);
_3 = _1;
_3 = copy _1;
_2 = move _3;
StorageDead(_3);
StorageLive(_4);
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/box_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
fn main() {
// CHECK-LABEL: fn main(
// CHECK: [[box:_.*]] = ShallowInitBox(
// CHECK: [[ptr:_.*]] = ((([[box]].0: std::ptr::Unique<S>).0: std::ptr::NonNull<S>).0: *const S);
// CHECK: [[ptr:_.*]] = copy ((([[box]].0: std::ptr::Unique<S>).0: std::ptr::NonNull<S>).0: *const S);
// CHECK: (*[[ptr]]) = S::new() -> [return: [[ret:bb.*]], unwind: [[unwind:bb.*]]];
// CHECK: [[ret]]: {
// CHECK: [[box2:_.*]] = move [[box]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body of b()}>, _2: &mut Context<'_>) ->
StorageLive(_13);
StorageLive(_14);
StorageLive(_15);
_15 = _38;
_15 = copy _38;
_14 = move _15;
goto -> bb6;
}
Expand Down Expand Up @@ -194,8 +194,8 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body of b()}>, _2: &mut Context<'_>) ->

bb10: {
StorageLive(_17);
_17 = ((_9 as Ready).0: ());
_3 = _17;
_17 = copy ((_9 as Ready).0: ());
_3 = copy _17;
StorageDead(_17);
StorageDead(_14);
StorageDead(_12);
Expand Down Expand Up @@ -253,7 +253,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body of b()}>, _2: &mut Context<'_>) ->
StorageLive(_29);
StorageLive(_30);
StorageLive(_31);
_31 = _38;
_31 = copy _38;
_30 = move _31;
goto -> bb18;
}
Expand Down Expand Up @@ -291,8 +291,8 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body of b()}>, _2: &mut Context<'_>) ->

bb21: {
StorageLive(_33);
_33 = ((_25 as Ready).0: ());
_37 = _33;
_33 = copy ((_25 as Ready).0: ());
_37 = copy _33;
StorageDead(_33);
StorageDead(_30);
StorageDead(_28);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ fn adt() -> Onion {
bb0: {
_1 = const 1_i32;
_2 = Foo { a: const 1_i32, b: const 2_i32 };
_3 = Bar::Foo(move _2, _1);
_0 = Onion { neon: ((_3 as variant#0).1: i32) };
_3 = Bar::Foo(move _2, copy _1);
_0 = Onion { neon: copy ((_3 as variant#0).1: i32) };
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn array() -> [i32; 2] {
bb0: {
_1 = [const 42_i32, const 43_i32];
_2 = const 1_i32;
_1 = [_2, const 2_i32];
_1 = [copy _2, const 2_i32];
_0 = move _1;
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ fn arbitrary_let(_1: i32) -> i32 {
let mut _3: i32;

bb0: {
_2 = _1;
_2 = copy _1;
goto -> bb2;
}

bb1: {
_0 = _3;
_0 = copy _3;
return;
}

bb2: {
_3 = _2;
_3 = copy _2;
goto -> bb1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn arrays() -> usize {
bb0: {
_1 = [const 5_i32; C];
_2 = Len(_1);
_0 = _2;
_0 = copy _2;
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn float_to_int(_1: f32) -> i32 {
let mut _0: i32;

bb0: {
_0 = _1 as i32 (FloatToInt);
_0 = copy _1 as i32 (FloatToInt);
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn int_to_int(_1: u32) -> i32 {
let mut _0: i32;

bb0: {
_0 = _1 as i32 (IntToInt);
_0 = copy _1 as i32 (IntToInt);
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn int_to_ptr(_1: usize) -> *const i32 {
let mut _0: *const i32;

bb0: {
_0 = _1 as *const i32 (PointerWithExposedProvenance);
_0 = copy _1 as *const i32 (PointerWithExposedProvenance);
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn assume_local(_1: bool) -> () {
let mut _0: ();

bb0: {
assume(_1);
assume(copy _1);
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn assume_place(_1: (bool, u8)) -> () {
let mut _0: ();

bb0: {
assume((_1.0: bool));
assume(copy (_1.0: bool));
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn switch_bool(_1: bool) -> u32 {
let mut _0: u32;

bb0: {
switchInt(_1) -> [1: bb1, 0: bb2, otherwise: bb2];
switchInt(copy _1) -> [1: bb1, 0: bb2, otherwise: bb2];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn switch_option(_1: Option<()>) -> bool {

bb0: {
_2 = discriminant(_1);
switchInt(_2) -> [0: bb1, 1: bb2, otherwise: bb2];
switchInt(copy _2) -> [0: bb1, 1: bb2, otherwise: bb2];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn switch_option_repr(_1: Bool) -> bool {

bb0: {
_2 = discriminant(_1);
switchInt(_2) -> [0: bb2, otherwise: bb1];
switchInt(copy _2) -> [0: bb2, otherwise: bb1];
}

bb1: {
Expand Down
Loading
Loading