Skip to content

Commit 749c8ad

Browse files
committed
Update tests
1 parent 7f3aebc commit 749c8ad

30 files changed

Lines changed: 316 additions & 446 deletions

‎tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl S {
2424
let this: Ptr<S> = __this.as_pointer();
2525
Rc::try_unwrap(__this).ok().unwrap().into_inner()
2626
}
27-
pub fn S_pmutS_rv(_a0: Ptr<S>) -> Self {
27+
pub fn move_from(_a0: Ptr<S>) -> Self {
2828
let __this: Value<S> = Rc::new(RefCell::new(Self {
2929
v: Rc::new(RefCell::new(std::mem::take(
3030
&mut (*(*_a0.upgrade().deref()).v.borrow_mut()),
@@ -84,18 +84,18 @@ fn main_0() -> i32 {
8484
pub fn shuffle_1(x: i32) -> i32 {
8585
let x: Value<i32> = Rc::new(RefCell::new(x));
8686
let a: Value<S> = Rc::new(RefCell::new(S::new({ (*x.borrow()) })));
87-
let b: Value<S> = Rc::new(RefCell::new(S::S_pmutS_rv({ a.as_pointer() })));
87+
let b: Value<S> = Rc::new(RefCell::new(S::move_from({ a.as_pointer() })));
8888
assert!((*(*a.borrow()).v.borrow()).is_empty());
8989
let c: Value<S> = Rc::new(RefCell::new(S::new({ 1 })));
90-
({ SImpl::operator_assign_pmutS_rv(&c.as_pointer(), b.as_pointer()) });
90+
({ SImpl::move_assign(&c.as_pointer(), b.as_pointer()) });
9191
assert!((*(*b.borrow()).v.borrow()).is_empty());
9292
return ({ sum_0(c.as_pointer()) });
9393
}
9494
pub trait SImpl {
95-
fn operator_assign_pmutS_rv(&self, _a0: Ptr<S>) -> Ptr<S>;
95+
fn move_assign(&self, _a0: Ptr<S>) -> Ptr<S>;
9696
}
9797
impl SImpl for Ptr<S> {
98-
fn operator_assign_pmutS_rv(&self, _a0: Ptr<S>) -> Ptr<S> {
98+
fn move_assign(&self, _a0: Ptr<S>) -> Ptr<S> {
9999
((*(*self).upgrade().deref()).v.as_pointer() as Ptr<Vec<i32>>).write(std::mem::take(
100100
&mut (*(*_a0.upgrade().deref()).v.borrow_mut()),
101101
));

‎tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ impl S {
2020
};
2121
this
2222
}
23-
pub unsafe fn S_pmutS_rv(_a0: *mut S) -> Self {
23+
pub unsafe fn move_from(_a0: *mut S) -> Self {
2424
let mut this = Self {
2525
v: std::mem::take(&mut (*_a0).v),
2626
n: std::array::from_fn::<_, 2, _>(|__i: usize| (*_a0).n[(__i)]),
2727
};
2828
this
2929
}
30-
pub unsafe fn operator_assign_pmutS_rv(&mut self, _a0: *mut S) -> *mut S {
30+
pub unsafe fn move_assign(&mut self, _a0: *mut S) -> *mut S {
3131
self.v = std::mem::take(&mut (*_a0).v);
3232
{
3333
if 8_usize != 0 {
@@ -67,10 +67,10 @@ unsafe fn main_0() -> i32 {
6767
}
6868
pub unsafe fn shuffle_1(mut x: i32) -> i32 {
6969
let mut a: S = S::new({ x });
70-
let mut b: S = S::S_pmutS_rv({ &mut a });
70+
let mut b: S = S::move_from({ &mut a });
7171
assert!(a.v.is_empty());
7272
let mut c: S = S::new({ 1 });
73-
(unsafe { S::operator_assign_pmutS_rv(&mut c, &mut b) });
73+
(unsafe { S::move_assign(&mut c, &mut b) });
7474
assert!(b.v.is_empty());
7575
return (unsafe { sum_0(&c) });
7676
}

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

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Partial {
2525
let this: Ptr<Partial> = __this.as_pointer();
2626
Rc::try_unwrap(__this).ok().unwrap().into_inner()
2727
}
28-
pub fn Partial_pconstPartial(o: Ptr<Partial>) -> Self {
28+
pub fn copy_from(o: Ptr<Partial>) -> Self {
2929
let __this: Value<Partial> = Rc::new(RefCell::new(Self {
3030
v: Rc::new(RefCell::new((*(*o.upgrade().deref()).v.borrow()))),
3131
keep: Rc::new(RefCell::new((*(*o.upgrade().deref()).keep.borrow()))),
@@ -40,7 +40,7 @@ impl Clone for Partial {
4040
v: self.v.clone(),
4141
keep: self.keep.clone(),
4242
}));
43-
Partial::Partial_pconstPartial(__src.as_pointer())
43+
Partial::copy_from(__src.as_pointer())
4444
}
4545
}
4646
impl ByteRepr for Partial {
@@ -146,14 +146,10 @@ pub struct Holder {
146146
impl Clone for Holder {
147147
fn clone(&self) -> Self {
148148
let __this: Value<Holder> = Rc::new(RefCell::new(Self {
149-
p: Rc::new(RefCell::new(Partial::Partial_pconstPartial({
150-
self.p.as_pointer()
151-
}))),
149+
p: Rc::new(RefCell::new(Partial::copy_from({ self.p.as_pointer() }))),
152150
arr: Rc::new(RefCell::new(Box::new(std::array::from_fn::<_, 2, _>(
153151
|__i: usize| {
154-
Partial::Partial_pconstPartial({
155-
(self.arr.as_pointer() as Ptr<Partial>).offset(__i)
156-
})
152+
Partial::copy_from({ (self.arr.as_pointer() as Ptr<Partial>).offset(__i) })
157153
},
158154
)))),
159155
}));
@@ -196,38 +192,38 @@ fn main_0() -> i32 {
196192
let a: Value<Partial> = Rc::new(RefCell::new(Partial::new({ 1 }, { 100 })));
197193
let b: Value<Partial> = Rc::new(RefCell::new(Partial::new({ 2 }, { 200 })));
198194
let c: Value<Partial> = Rc::new(RefCell::new(Partial::new({ 3 }, { 300 })));
199-
({ PartialImpl::operator_assign(&a.as_pointer(), b.as_pointer()) });
195+
({ PartialImpl::copy_assign(&a.as_pointer(), b.as_pointer()) });
200196
assert!(((*(*a.borrow()).v.borrow()) == 2) && ((*(*a.borrow()).keep.borrow()) == 100));
201197
assert!((assigns_0.with(|rc| *rc.borrow()) == 1));
202198
({
203-
PartialImpl::operator_assign(
199+
PartialImpl::copy_assign(
204200
&c.as_pointer(),
205-
({ PartialImpl::operator_assign(&a.as_pointer(), b.as_pointer()) }),
201+
({ PartialImpl::copy_assign(&a.as_pointer(), b.as_pointer()) }),
206202
)
207203
});
208204
assert!(((*(*c.borrow()).v.borrow()) == 2) && ((*(*c.borrow()).keep.borrow()) == 300));
209205
assert!((assigns_0.with(|rc| *rc.borrow()) == 3));
210206
({
211207
let _o: Ptr<Partial> = a.as_pointer();
212-
PartialImpl::operator_assign(&a.as_pointer(), _o)
208+
PartialImpl::copy_assign(&a.as_pointer(), _o)
213209
});
214210
assert!((assigns_0.with(|rc| *rc.borrow()) == 3));
215211
({
216212
let _o: Value<Partial> = Rc::new(RefCell::new(Partial::new({ 9 }, { 900 })));
217-
PartialImpl::operator_assign(&a.as_pointer(), _o.as_pointer())
213+
PartialImpl::copy_assign(&a.as_pointer(), _o.as_pointer())
218214
});
219215
assert!(((*(*a.borrow()).v.borrow()) == 9) && ((*(*a.borrow()).keep.borrow()) == 100));
220216
assert!((assigns_0.with(|rc| *rc.borrow()) == 4));
221217
let ra: Ptr<Partial> = a.as_pointer();
222218
({
223219
let _o: Ptr<Partial> = c.as_pointer();
224-
PartialImpl::operator_assign(&ra, _o)
220+
PartialImpl::copy_assign(&ra, _o)
225221
});
226222
assert!(((*(*a.borrow()).v.borrow()) == 2));
227223
let pa: Value<Ptr<Partial>> = Rc::new(RefCell::new((a.as_pointer())));
228224
({
229225
let _o: Ptr<Partial> = b.as_pointer();
230-
PartialImpl::operator_assign(&(*pa.borrow()), _o)
226+
PartialImpl::copy_assign(&(*pa.borrow()), _o)
231227
});
232228
assert!(((*(*a.borrow()).v.borrow()) == 2));
233229
assert!((assigns_0.with(|rc| *rc.borrow()) == 6));
@@ -238,9 +234,9 @@ fn main_0() -> i32 {
238234
Partial::new({ 6 }, { 60 }),
239235
]))),
240236
}));
241-
({ PartialImpl::operator_assign(&(*h.borrow()).p.as_pointer(), b.as_pointer()) });
237+
({ PartialImpl::copy_assign(&(*h.borrow()).p.as_pointer(), b.as_pointer()) });
242238
({
243-
PartialImpl::operator_assign(
239+
PartialImpl::copy_assign(
244240
&((*h.borrow()).arr.as_pointer() as Ptr<Partial>).offset(1),
245241
c.as_pointer(),
246242
)
@@ -266,7 +262,7 @@ fn main_0() -> i32 {
266262
assert!(((*(*n2.borrow()).mark.borrow()) == 10));
267263
let r: Value<RefQualified> = Rc::new(RefCell::new(RefQualified::new()));
268264
let r1: Value<RefQualified> = Rc::new(RefCell::new(RefQualified::new()));
269-
({ RefQualifiedImpl::operator_assign(&r1.as_pointer(), r.as_pointer()) });
265+
({ RefQualifiedImpl::copy_assign(&r1.as_pointer(), r.as_pointer()) });
270266
assert!(((*(*r1.borrow()).mark.borrow()) == 1));
271267
return 0;
272268
}
@@ -287,10 +283,10 @@ impl NonConstAssignImpl for Ptr<NonConstAssign> {
287283
}
288284
}
289285
pub trait PartialImpl {
290-
fn operator_assign(&self, o: Ptr<Partial>) -> Ptr<Partial>;
286+
fn copy_assign(&self, o: Ptr<Partial>) -> Ptr<Partial>;
291287
}
292288
impl PartialImpl for Ptr<Partial> {
293-
fn operator_assign(&self, o: Ptr<Partial>) -> Ptr<Partial> {
289+
fn copy_assign(&self, o: Ptr<Partial>) -> Ptr<Partial> {
294290
if ((*self) == (o)) {
295291
return (*self).clone();
296292
}
@@ -301,10 +297,10 @@ impl PartialImpl for Ptr<Partial> {
301297
}
302298
}
303299
pub trait RefQualifiedImpl {
304-
fn operator_assign(&self, o: Ptr<RefQualified>) -> Ptr<RefQualified>;
300+
fn copy_assign(&self, o: Ptr<RefQualified>) -> Ptr<RefQualified>;
305301
}
306302
impl RefQualifiedImpl for Ptr<RefQualified> {
307-
fn operator_assign(&self, o: Ptr<RefQualified>) -> Ptr<RefQualified> {
303+
fn copy_assign(&self, o: Ptr<RefQualified>) -> Ptr<RefQualified> {
308304
let __rhs = ((*(*o.upgrade().deref()).mark.borrow()) + 1);
309305
(*(*(*self).upgrade().deref()).mark.borrow_mut()) = __rhs;
310306
return (*self).clone();

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

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Counted {
2222
let this: Ptr<Counted> = __this.as_pointer();
2323
Rc::try_unwrap(__this).ok().unwrap().into_inner()
2424
}
25-
pub fn Counted_pconstCounted(o: Ptr<Counted>) -> Self {
25+
pub fn copy_from(o: Ptr<Counted>) -> Self {
2626
let __this: Value<Counted> = Rc::new(RefCell::new(Self {
2727
v: Rc::new(RefCell::new((*(*o.upgrade().deref()).v.borrow()))),
2828
}));
@@ -34,7 +34,7 @@ impl Counted {
3434
impl Clone for Counted {
3535
fn clone(&self) -> Self {
3636
let __src: Value<Counted> = Rc::new(RefCell::new(Counted { v: self.v.clone() }));
37-
Counted::Counted_pconstCounted(__src.as_pointer())
37+
Counted::copy_from(__src.as_pointer())
3838
}
3939
}
4040
impl ByteRepr for Counted {
@@ -116,7 +116,7 @@ impl Ignored {
116116
let this: Ptr<Ignored> = __this.as_pointer();
117117
Rc::try_unwrap(__this).ok().unwrap().into_inner()
118118
}
119-
pub fn Ignored_pconstIgnored(_a0: Ptr<Ignored>) -> Self {
119+
pub fn copy_from(_a0: Ptr<Ignored>) -> Self {
120120
let __this: Value<Ignored> = Rc::new(RefCell::new(Self {
121121
v: Rc::new(RefCell::new(-1_i32)),
122122
}));
@@ -128,7 +128,7 @@ impl Ignored {
128128
impl Clone for Ignored {
129129
fn clone(&self) -> Self {
130130
let __src: Value<Ignored> = Rc::new(RefCell::new(Ignored { v: self.v.clone() }));
131-
Ignored::Ignored_pconstIgnored(__src.as_pointer())
131+
Ignored::copy_from(__src.as_pointer())
132132
}
133133
}
134134
impl ByteRepr for Ignored {
@@ -152,14 +152,10 @@ pub struct Holder {
152152
impl Clone for Holder {
153153
fn clone(&self) -> Self {
154154
let __this: Value<Holder> = Rc::new(RefCell::new(Self {
155-
c: Rc::new(RefCell::new(Counted::Counted_pconstCounted({
156-
self.c.as_pointer()
157-
}))),
155+
c: Rc::new(RefCell::new(Counted::copy_from({ self.c.as_pointer() }))),
158156
arr: Rc::new(RefCell::new(Box::new(std::array::from_fn::<_, 2, _>(
159157
|__i: usize| {
160-
Counted::Counted_pconstCounted({
161-
(self.arr.as_pointer() as Ptr<Counted>).offset(__i)
162-
})
158+
Counted::copy_from({ (self.arr.as_pointer() as Ptr<Counted>).offset(__i) })
163159
},
164160
)))),
165161
}));
@@ -201,29 +197,23 @@ pub fn by_value_1(c: Counted) -> i32 {
201197
pub fn make_2(v: i32) -> Counted {
202198
let v: Value<i32> = Rc::new(RefCell::new(v));
203199
let c: Value<Counted> = Rc::new(RefCell::new(Counted::new({ (*v.borrow()) })));
204-
return Counted::Counted_pconstCounted({ c.as_pointer() });
200+
return Counted::copy_from({ c.as_pointer() });
205201
}
206202
pub fn main() {
207203
__cpp2rust_init_globals();
208204
std::process::exit(main_0());
209205
}
210206
fn main_0() -> i32 {
211207
let a: Value<Counted> = Rc::new(RefCell::new(Counted::new({ 1 })));
212-
let b: Value<Counted> = Rc::new(RefCell::new(Counted::Counted_pconstCounted({
213-
a.as_pointer()
214-
})));
215-
let c: Value<Counted> = Rc::new(RefCell::new(Counted::Counted_pconstCounted({
216-
a.as_pointer()
217-
})));
218-
let d: Value<Counted> = Rc::new(RefCell::new(Counted::Counted_pconstCounted({
219-
a.as_pointer()
220-
})));
208+
let b: Value<Counted> = Rc::new(RefCell::new(Counted::copy_from({ a.as_pointer() })));
209+
let c: Value<Counted> = Rc::new(RefCell::new(Counted::copy_from({ a.as_pointer() })));
210+
let d: Value<Counted> = Rc::new(RefCell::new(Counted::copy_from({ a.as_pointer() })));
221211
assert!((copies_0.with(|rc| *rc.borrow()) == 3));
222212
assert!(
223213
(((*(*b.borrow()).v.borrow()) == 1) && ((*(*c.borrow()).v.borrow()) == 1))
224214
&& ((*(*d.borrow()).v.borrow()) == 1)
225215
);
226-
assert!((({ by_value_1(Counted::Counted_pconstCounted({ a.as_pointer() },),) }) == 1));
216+
assert!((({ by_value_1(Counted::copy_from({ a.as_pointer() },),) }) == 1));
227217
assert!((copies_0.with(|rc| *rc.borrow()) == 4));
228218
let e: Value<Counted> = Rc::new(RefCell::new(({ make_2(5) })));
229219
assert!(((*(*e.borrow()).v.borrow()) == 5));
@@ -232,9 +222,7 @@ fn main_0() -> i32 {
232222
assert!(((*(*f.borrow()).v.borrow()) == 6));
233223
assert!((copies_0.with(|rc| *rc.borrow()) == 5));
234224
let g: Value<Counted> = Rc::new(RefCell::new(Counted::new({ 7 })));
235-
let h: Value<Counted> = Rc::new(RefCell::new(Counted::Counted_pconstCounted({
236-
g.as_pointer()
237-
})));
225+
let h: Value<Counted> = Rc::new(RefCell::new(Counted::copy_from({ g.as_pointer() })));
238226
assert!(((*(*h.borrow()).v.borrow()) == 7));
239227
assert!((copies_0.with(|rc| *rc.borrow()) == 6));
240228
let hold: Value<Holder> = Rc::new(RefCell::new(Holder {
@@ -267,9 +255,7 @@ fn main_0() -> i32 {
267255
);
268256
assert!((copies_0.with(|rc| *rc.borrow()) == 10));
269257
let i1: Value<Ignored> = Rc::new(RefCell::new(Ignored::new({ 1 })));
270-
let i2: Value<Ignored> = Rc::new(RefCell::new(Ignored::Ignored_pconstIgnored({
271-
i1.as_pointer()
272-
})));
258+
let i2: Value<Ignored> = Rc::new(RefCell::new(Ignored::copy_from({ i1.as_pointer() })));
273259
assert!(((*(*i1.borrow()).v.borrow()) == 1) && ((*(*i2.borrow()).v.borrow()) == -1_i32));
274260
assert!((copies_0.with(|rc| *rc.borrow()) == 11));
275261
let n: Value<NonConst> = Rc::new(RefCell::new(NonConst::new()));

0 commit comments

Comments
 (0)