Skip to content

Commit 34dd801

Browse files
committed
Update tesst
1 parent c234c56 commit 34dd801

11 files changed

Lines changed: 66 additions & 101 deletions

‎tests/unit/out/refcount/structured_binding_array.rs‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@ pub fn main() {
1212
}
1313
fn main_0() -> i32 {
1414
let arr: Value<Box<[i32]>> = Rc::new(RefCell::new(Box::new([1, 2, 3])));
15-
let __decomp_0: Value<Box<[i32]>> =
16-
Rc::new(RefCell::new(Box::new(std::array::from_fn::<_, 3, _>(
17-
|__i: usize| (*arr.borrow())[(__i) as usize],
18-
))));
19-
(*__decomp_0.borrow_mut())[(0) as usize] = 10;
20-
assert!(((*__decomp_0.borrow())[(0) as usize] == 10));
21-
assert!(((*__decomp_0.borrow())[(1) as usize] == 2));
22-
assert!(((*__decomp_0.borrow())[(2) as usize] == 3));
15+
let mut __decomp_0: [i32; 3] = Box::new(std::array::from_fn::<_, 3, _>(|__i: usize| {
16+
(*arr.borrow())[(__i) as usize]
17+
}));
18+
__decomp_0[(0) as usize] = 10;
19+
assert!((__decomp_0[(0) as usize] == 10));
20+
assert!((__decomp_0[(1) as usize] == 2));
21+
assert!((__decomp_0[(2) as usize] == 3));
2322
assert!(((*arr.borrow())[(0) as usize] == 1));
24-
let __decomp_1: Ptr<i32> = (arr.as_pointer() as Ptr<i32>);
23+
let __decomp_1: Ptr<i32> = arr.as_pointer();
2524
elem!((__decomp_1), 0).write(7);
2625
{
27-
let _ptr = elem!((__decomp_1), 2);
28-
_ptr.write(_ptr.read() + (elem!((__decomp_1), 1).read()))
26+
let __rhs = (elem!((__decomp_1), 1).read());
27+
elem!((__decomp_1), 2).with_mut(|__v| *__v = *__v + __rhs)
2928
};
3029
assert!(((*arr.borrow())[(0) as usize] == 7));
3130
assert!(((*arr.borrow())[(2) as usize] == 5));

‎tests/unit/out/refcount/structured_binding_copy_ctor.rs‎

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,16 @@ pub struct Counted {
1818
pub y: i32,
1919
}
2020
impl Counted {
21-
pub fn new(x: i32, y: i32) -> Self {
22-
let x: Value<i32> = Rc::new(RefCell::new(x));
23-
let y: Value<i32> = Rc::new(RefCell::new(y));
24-
let __this: Value<Counted> = Rc::new(RefCell::new(Self {
25-
x: (*x.borrow()),
26-
y: (*y.borrow()),
27-
}));
28-
let this: Ptr<Counted> = __this.as_pointer();
29-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
21+
pub fn new(mut x: i32, mut y: i32) -> Self {
22+
Self { x: x, y: y }
3023
}
3124
pub fn copy_from(other: Ptr<Counted>) -> Self {
32-
let __this: Value<Counted> = Rc::new(RefCell::new(Self {
25+
let __this: Counted = Self {
3326
x: (other.with(|__s| __s.x) * 2),
3427
y: (other.with(|__s| __s.y) * 2),
35-
}));
36-
let this: Ptr<Counted> = __this.as_pointer();
28+
};
3729
(*copies_0.with(Value::clone).borrow_mut()).prefix_inc();
38-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
30+
__this
3931
}
4032
}
4133
impl Clone for Counted {
@@ -56,21 +48,21 @@ pub fn main() {
5648
}
5749
fn main_0() -> i32 {
5850
let s: Value<Counted> = Rc::new(RefCell::new(Counted::new({ 1 }, { 2 })));
59-
let __decomp_2: Value<Counted> = Rc::new(RefCell::new(Counted::copy_from({ s.as_pointer() })));
51+
let mut __decomp_2: Counted = Counted::copy_from({ s.as_pointer() });
6052
assert!((copies_0.with(|rc| *rc.borrow()) == 1));
61-
assert!(({ (*__decomp_2.borrow()).x } == 2));
62-
assert!(({ (*__decomp_2.borrow()).y } == 4));
53+
assert!((__decomp_2.x == 2));
54+
assert!((__decomp_2.y == 4));
6355
let __decomp_3: Ptr<Counted> = s.as_pointer();
6456
assert!((copies_0.with(|rc| *rc.borrow()) == 1));
6557
assert!((__decomp_3.with(|__s| __s.x) == 1));
6658
assert!((__decomp_3.with(|__s| __s.y) == 2));
6759
let __decomp_4: Ptr<Counted> = s.as_pointer();
6860
assert!((copies_0.with(|rc| *rc.borrow()) == 1));
6961
assert!((__decomp_4.with(|__s| __s.x) == 1));
70-
let __decomp_5: Value<Counted> = Rc::new(RefCell::new(({ make_counted_1() })));
62+
let mut __decomp_5: Counted = ({ make_counted_1() });
7163
assert!((copies_0.with(|rc| *rc.borrow()) == 1));
72-
assert!(({ (*__decomp_5.borrow()).x } == 5));
73-
assert!(({ (*__decomp_5.borrow()).y } == 6));
64+
assert!((__decomp_5.x == 5));
65+
assert!((__decomp_5.y == 6));
7466
return 0;
7567
}
7668
pub fn __cpp2rust_init_globals() {

‎tests/unit/out/refcount/structured_binding_move_ctor.rs‎

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ thread_local!(
1212
thread_local!(
1313
pub static moves_1: Value<i32> = Rc::new(RefCell::new(0));
1414
);
15-
#[derive(Record, ByteRepr, VaArg, FnPtrArg, Default)]
15+
#[derive(Record, ByteRepr, VaArg, FnPtrArg, MoveCtor, Default)]
1616
#[byte_size(8)]
1717
pub struct Movable {
1818
#[offset(0)]
@@ -21,35 +21,26 @@ pub struct Movable {
2121
pub y: i32,
2222
}
2323
impl Movable {
24-
pub fn new(x: i32, y: i32) -> Self {
25-
let x: Value<i32> = Rc::new(RefCell::new(x));
26-
let y: Value<i32> = Rc::new(RefCell::new(y));
27-
let __this: Value<Movable> = Rc::new(RefCell::new(Self {
28-
x: (*x.borrow()),
29-
y: (*y.borrow()),
30-
}));
31-
let this: Ptr<Movable> = __this.as_pointer();
32-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
24+
pub fn new(mut x: i32, mut y: i32) -> Self {
25+
Self { x: x, y: y }
3326
}
3427
pub fn copy_from(other: Ptr<Movable>) -> Self {
35-
let __this: Value<Movable> = Rc::new(RefCell::new(Self {
28+
let __this: Movable = Self {
3629
x: other.with(|__s| __s.x),
3730
y: other.with(|__s| __s.y),
38-
}));
39-
let this: Ptr<Movable> = __this.as_pointer();
31+
};
4032
(*copies_0.with(Value::clone).borrow_mut()).prefix_inc();
41-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
33+
__this
4234
}
4335
pub fn move_from(other: Ptr<Movable>) -> Self {
44-
let __this: Value<Movable> = Rc::new(RefCell::new(Self {
36+
let __this: Movable = Self {
4537
x: other.with(|__s| __s.x),
4638
y: other.with(|__s| __s.y),
47-
}));
48-
let this: Ptr<Movable> = __this.as_pointer();
39+
};
4940
field!(other, x).write(0);
5041
field!(other, y).write(0);
5142
(*moves_1.with(Value::clone).borrow_mut()).prefix_inc();
52-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
43+
__this
5344
}
5445
}
5546
impl Clone for Movable {
@@ -77,37 +68,22 @@ pub fn main() {
7768
}
7869
fn main_0() -> i32 {
7970
let m: Value<Movable> = Rc::new(RefCell::new(Movable::new({ 3 }, { 4 })));
80-
let __decomp_2: Value<Movable> = Rc::new(RefCell::new(Movable::move_from({ m.as_pointer() })));
71+
let mut __decomp_2: Movable = Movable::move_from({ m.as_pointer() });
8172
assert!((moves_1.with(|rc| *rc.borrow()) == 1));
8273
assert!((copies_0.with(|rc| *rc.borrow()) == 0));
83-
assert!(({ (*__decomp_2.borrow()).x } == 3));
84-
assert!(({ (*__decomp_2.borrow()).y } == 4));
74+
assert!((__decomp_2.x == 3));
75+
assert!((__decomp_2.y == 4));
8576
assert!(({ (*m.borrow()).x } == 0));
8677
assert!(({ (*m.borrow()).y } == 0));
8778
let h: Value<Holder> = Rc::new(RefCell::new(Holder {
8879
xs: Rc::new(RefCell::new(vec![1, 2, 3])),
8980
ys: Rc::new(RefCell::new(vec![4, 5])),
9081
}));
91-
let __decomp_3: Value<Holder> =
92-
Rc::new(RefCell::new(({ HolderImpl::extract(&h.as_pointer()) })));
93-
assert!(((*{ (*__decomp_3.borrow()).xs.clone() }.borrow()).len() == 3_usize));
94-
assert!(((*{ (*__decomp_3.borrow()).ys.clone() }.borrow()).len() == 2_usize));
95-
assert!(
96-
((elem!(
97-
({ (*__decomp_3.borrow()).xs.as_pointer() } as Ptr<i32>),
98-
2_usize
99-
)
100-
.read())
101-
== 3)
102-
);
103-
assert!(
104-
((elem!(
105-
({ (*__decomp_3.borrow()).ys.as_pointer() } as Ptr<i32>),
106-
0_usize
107-
)
108-
.read())
109-
== 4)
110-
);
82+
let mut __decomp_3: Holder = ({ HolderImpl::extract(&h.as_pointer()) });
83+
assert!(((*__decomp_3.xs.borrow()).len() == 3_usize));
84+
assert!(((*__decomp_3.ys.borrow()).len() == 2_usize));
85+
assert!(((elem!((__decomp_3.xs.as_pointer() as Ptr<i32>), 2_usize).read()) == 3));
86+
assert!(((elem!((__decomp_3.ys.as_pointer() as Ptr<i32>), 0_usize).read()) == 4));
11187
assert!((*{ (*h.borrow()).xs.clone() }.borrow()).is_empty());
11288
assert!((*{ (*h.borrow()).ys.clone() }.borrow()).is_empty());
11389
return 0;

‎tests/unit/out/refcount/structured_binding_range_for.rs‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,24 @@ fn main_0() -> i32 {
3535
])));
3636
'loop_: for mut __decomp_0 in arr.as_pointer() as Ptr<Pair> {
3737
{
38-
let _ptr = field!(__decomp_0, first);
39-
_ptr.write(_ptr.read() + __decomp_0.with(|__s| __s.second))
38+
let __rhs = __decomp_0.with(|__s| __s.second);
39+
field!(__decomp_0, first).with_mut(|__v| *__v = *__v + __rhs)
4040
};
4141
}
4242
assert!(({ (*arr.borrow())[(0) as usize].first } == 3));
4343
assert!(({ (*arr.borrow())[(2) as usize].first } == 11));
4444
'loop_: for mut __decomp_1 in arr.as_pointer() as Ptr<Pair> {
45-
let __decomp_1: Value<Pair> = Rc::new(RefCell::new(__decomp_1.upgrade().deref().clone()));
46-
(*__decomp_1.borrow_mut()).first = 0;
47-
(*__decomp_1.borrow_mut()).second = 0;
45+
let mut __decomp_1: Pair = __decomp_1.upgrade().deref().clone();
46+
__decomp_1.first = 0;
47+
__decomp_1.second = 0;
4848
}
4949
assert!(({ (*arr.borrow())[(1) as usize].first } == 7));
5050
assert!(({ (*arr.borrow())[(1) as usize].second } == 4));
51-
let sum: Value<i32> = Rc::new(RefCell::new(0));
51+
let mut sum: i32 = 0;
5252
'loop_: for mut __decomp_2 in arr.as_pointer() as Ptr<Pair> {
53-
(*sum.borrow_mut()) +=
54-
(__decomp_2.with(|__s| __s.first) * __decomp_2.with(|__s| __s.second));
53+
sum += (__decomp_2.with(|__s| __s.first) * __decomp_2.with(|__s| __s.second));
5554
}
56-
assert!(((*sum.borrow()) == (((3 * 2) + (7 * 4)) + (11 * 6))));
55+
assert!((sum == (((3 * 2) + (7 * 4)) + (11 * 6))));
5756
return 0;
5857
}
5958
pub fn __cpp2rust_init_globals() {}

‎tests/unit/out/refcount/structured_binding_ref.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ fn main_0() -> i32 {
3535
field!(__decomp_2, a).write(11);
3636
field!(__decomp_2, b).write(true);
3737
{
38-
let _ptr = field!(__decomp_2, c);
39-
_ptr.write(_ptr.read() + 1)
38+
field!(__decomp_2, c).with_mut(|__v| *__v = *__v + 1)
4039
};
4140
assert!(({ (*t.borrow()).a } == 11));
4241
assert!({ (*t.borrow()).b });

‎tests/unit/out/refcount/structured_binding_trivial.rs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ pub fn main() {
1919
std::process::exit(main_0());
2020
}
2121
fn main_0() -> i32 {
22-
let __decomp_0: Value<Pair> = Rc::new(RefCell::new(Pair {
22+
let mut __decomp_0: Pair = Pair {
2323
first: 1,
2424
second: 2,
25-
}));
26-
assert!(({ (*__decomp_0.borrow()).first } == 1));
27-
assert!(({ (*__decomp_0.borrow()).second } == 2));
28-
let p: Value<Pair> = Rc::new(RefCell::new(Pair {
25+
};
26+
assert!((__decomp_0.first == 1));
27+
assert!((__decomp_0.second == 2));
28+
let mut p: Pair = Pair {
2929
first: 10,
3030
second: 20,
31-
}));
32-
let __decomp_1: Value<Pair> = Rc::new(RefCell::new((*p.borrow()).clone()));
33-
(*__decomp_1.borrow_mut()).first = 11;
34-
(*__decomp_1.borrow_mut()).second += 1;
35-
assert!(({ (*__decomp_1.borrow()).first } == 11));
36-
assert!(({ (*__decomp_1.borrow()).second } == 21));
37-
assert!(({ (*p.borrow()).first } == 10));
38-
assert!(({ (*p.borrow()).second } == 20));
31+
};
32+
let mut __decomp_1: Pair = (p).clone();
33+
__decomp_1.first = 11;
34+
__decomp_1.second += 1;
35+
assert!((__decomp_1.first == 11));
36+
assert!((__decomp_1.second == 21));
37+
assert!((p.first == 10));
38+
assert!((p.second == 20));
3939
return 0;
4040
}
4141
pub fn __cpp2rust_init_globals() {}

‎tests/unit/out/unsafe/structured_binding_copy_ctor.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
99
pub static mut copies_0: std::cell::LazyCell<i32> = std::cell::LazyCell::new(|| unsafe { 0 });
1010
#[repr(C)]
11-
#[derive(VaArg, Default)]
11+
#[derive(VaArg, FnPtrArg, Default)]
1212
pub struct Counted {
1313
pub x: i32,
1414
pub y: i32,

‎tests/unit/out/unsafe/structured_binding_move_ctor.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::rc::Rc;
99
pub static mut copies_0: std::cell::LazyCell<i32> = std::cell::LazyCell::new(|| unsafe { 0 });
1010
pub static mut moves_1: std::cell::LazyCell<i32> = std::cell::LazyCell::new(|| unsafe { 0 });
1111
#[repr(C)]
12-
#[derive(VaArg, Default)]
12+
#[derive(VaArg, FnPtrArg, MoveCtorUnsafe, Default)]
1313
pub struct Movable {
1414
pub x: i32,
1515
pub y: i32,
@@ -44,7 +44,7 @@ impl Clone for Movable {
4444
}
4545
}
4646
#[repr(C)]
47-
#[derive(Clone, VaArg, Default)]
47+
#[derive(Clone, VaArg, FnPtrArg, Default)]
4848
pub struct Holder {
4949
pub xs: Vec<i32>,
5050
pub ys: Vec<i32>,

‎tests/unit/out/unsafe/structured_binding_range_for.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
99
#[repr(C)]
10-
#[derive(Copy, Clone, VaArg, Default)]
10+
#[derive(Copy, Clone, VaArg, FnPtrArg, Default)]
1111
pub struct Pair {
1212
pub first: i32,
1313
pub second: i32,

‎tests/unit/out/unsafe/structured_binding_ref.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
99
#[repr(C)]
10-
#[derive(Copy, Clone, VaArg, Default)]
10+
#[derive(Copy, Clone, VaArg, FnPtrArg, Default)]
1111
pub struct Triple {
1212
pub a: i32,
1313
pub b: bool,

0 commit comments

Comments
 (0)