Skip to content

Commit 66d35c4

Browse files
committed
Update tests
1 parent 285428f commit 66d35c4

12 files changed

Lines changed: 94 additions & 39 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ pub fn unrelated3_3() -> i32 {
2424
}
2525
pub fn helper_0(x: i32) -> i32 {
2626
let x: Value<i32> = Rc::new(RefCell::new(x));
27-
({ unrelated1_1() });
28-
({ unrelated2_2() });
29-
({ unrelated3_3() });
27+
&({ unrelated1_1() });
28+
&({ unrelated2_2() });
29+
&({ unrelated3_3() });
3030
return ((*x.borrow()) + 1);
3131
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ pub fn unrelated3_3() -> i32 {
2424
}
2525
pub fn helper_0(x: i32) -> i32 {
2626
let x: Value<i32> = Rc::new(RefCell::new(x));
27-
({ unrelated1_1() });
28-
({ unrelated2_2() });
29-
({ unrelated3_3() });
27+
&({ unrelated1_1() });
28+
&({ unrelated2_2() });
29+
&({ unrelated3_3() });
3030
return ((*x.borrow()) + 1);
3131
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ fn main_0() -> i32 {
4949
}
5050
pub fn touch_0(c: Ptr<container>) {
5151
let c: Value<Ptr<container>> = Rc::new(RefCell::new(c));
52-
(*(*(*c.borrow()).upgrade().deref()).p.borrow()).clone();
52+
&(*(*(*c.borrow()).upgrade().deref()).p.borrow());
5353
}
5454
pub struct opaque;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn main_0() -> i32 {
4242
p: Rc::new(RefCell::new(Ptr::<opaque>::null())),
4343
x: Rc::new(RefCell::new(42)),
4444
}));
45-
(*(*c.borrow()).p.borrow()).clone();
45+
&(*(*c.borrow()).p.borrow());
4646
return ((*(*c.borrow()).x.borrow()) - 42);
4747
}
4848
pub struct opaque;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ fn main_0() -> i32 {
1515
let x: Value<u8> = Rc::new(RefCell::new(
1616
((*bytes.borrow()).offset((4) as isize).read()),
1717
));
18-
(*x.borrow_mut());
18+
&(*x.borrow_mut());
1919
return 0;
2020
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ fn main_0() -> i32 {
1313
let b: Value<u8> = Rc::new(RefCell::new(66_u8));
1414
let p: Value<Ptr<u32>> = Rc::new(RefCell::new((b.as_pointer()).reinterpret_cast::<u32>()));
1515
let val: Value<u32> = Rc::new(RefCell::new(((*p.borrow()).read())));
16-
(*val.borrow_mut());
16+
&(*val.borrow_mut());
1717
return 0;
1818
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use std::rc::{Rc, Weak};
99
pub fn fopen_0(path: Ptr<u8>, mode: Ptr<u8>) -> Ptr<CFile> {
1010
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(path));
1111
let mode: Value<Ptr<u8>> = Rc::new(RefCell::new(mode));
12-
(*path.borrow()).clone();
13-
(*mode.borrow()).clone();
12+
&(*path.borrow());
13+
&(*mode.borrow());
1414
return Ptr::null();
1515
}
1616
pub fn main() {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ pub fn not_supported_5(ctx: AnyPtr, fn_: FnPtr<fn(i32) -> i32>, extra: AnyPtr) -
4646
let ctx: Value<AnyPtr> = Rc::new(RefCell::new(ctx));
4747
let fn_: Value<FnPtr<fn(i32) -> i32>> = Rc::new(RefCell::new(fn_));
4848
let extra: Value<AnyPtr> = Rc::new(RefCell::new(extra));
49-
(*ctx.borrow()).clone();
50-
(*fn_.borrow()).clone();
51-
(*extra.borrow()).clone();
49+
&(*ctx.borrow());
50+
&(*fn_.borrow());
51+
&(*extra.borrow());
5252
return -3_i32;
5353
}
5454
pub fn main() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::rc::{Rc, Weak};
99
pub fn logf_impl_0(fmt: Ptr<u8>, ap: VaList) -> i32 {
1010
let fmt: Value<Ptr<u8>> = Rc::new(RefCell::new(fmt));
1111
let ap: Value<VaList> = Rc::new(RefCell::new(ap));
12-
(*fmt.borrow()).clone();
12+
&(*fmt.borrow());
1313
return {
1414
let _lhs = (*ap.borrow_mut()).arg::<i32>();
1515
_lhs + (*ap.borrow_mut()).arg::<i32>()

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

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn unused_param_0(x: i32) {
1010
let x: Value<i32> = Rc::new(RefCell::new(x));
11-
(*x.borrow_mut());
11+
&(*x.borrow_mut());
1212
}
1313
#[derive(Default)]
1414
pub struct NonTrivial {
@@ -36,11 +36,11 @@ impl ByteRepr for NonTrivial {
3636
}
3737
}
3838
pub fn unused_ref_param_1(x: Ptr<NonTrivial>) {
39-
(*x.upgrade().deref()).clone();
39+
&(*x.upgrade().deref());
4040
}
4141
pub fn unused_ptr_param_2(p: Ptr<NonTrivial>) {
4242
let p: Value<Ptr<NonTrivial>> = Rc::new(RefCell::new(p));
43-
(*(*p.borrow()).upgrade().deref()).clone();
43+
&(*(*p.borrow()).upgrade().deref());
4444
}
4545
thread_local!(
4646
pub static side_effect_counter_3: Value<i32> = Rc::new(RefCell::new(0));
@@ -74,68 +74,95 @@ impl ByteRepr for Holder {
7474
}
7575
}
7676
}
77+
#[derive(Default)]
78+
pub struct NonCopyable {
79+
pub value: Value<Option<Value<i32>>>,
80+
}
81+
impl ByteRepr for NonCopyable {
82+
fn byte_size() -> usize {
83+
8
84+
}
85+
fn to_bytes(&self, buf: &mut [u8]) {
86+
(*self.value.borrow()).to_bytes(&mut buf[0..8]);
87+
}
88+
fn from_bytes(buf: &[u8]) -> Self {
89+
Self {
90+
value: Rc::new(RefCell::new(<Option<Value<i32>>>::from_bytes(&buf[0..8]))),
91+
}
92+
}
93+
}
94+
pub fn unused_noncopyable_param_5(x: Ptr<NonCopyable>) {
95+
&(*x.upgrade().deref());
96+
}
7797
pub fn main() {
7898
std::process::exit(main_0());
7999
}
80100
fn main_0() -> i32 {
81101
({ unused_param_0(42) });
82102
let y: Value<i32> = Rc::new(RefCell::new(5));
83-
(*y.borrow_mut());
103+
&(*y.borrow_mut());
84104
let z: Value<i32> = Rc::new(RefCell::new({
85-
(*y.borrow_mut());
105+
&(*y.borrow_mut());
86106
7
87107
}));
88108
assert!(((*z.borrow()) == 7));
89109
let counter: Value<i32> = Rc::new(RefCell::new(0));
90110
let w: Value<i32> = Rc::new(RefCell::new({
91-
(*counter.borrow_mut());
111+
&(*counter.borrow_mut());
92112
(*counter.borrow_mut()) = 3;
93113
(*counter.borrow())
94114
}));
95115
assert!(((*w.borrow()) == 3));
96116
assert!(((*counter.borrow()) == 3));
97-
({ bump_and_return_4() });
117+
&({ bump_and_return_4() });
98118
assert!(((*side_effect_counter_3.with(Value::clone).borrow()) == 1));
99119
let v: Value<i32> = Rc::new(RefCell::new({
100-
({ bump_and_return_4() });
120+
&({ bump_and_return_4() });
101121
99
102122
}));
103123
assert!(((*side_effect_counter_3.with(Value::clone).borrow()) == 2));
104124
assert!(((*v.borrow()) == 99));
105-
0;
106-
(0);
107-
(*y.borrow_mut());
108-
(0);
109-
(*y.borrow_mut());
125+
&(0);
126+
&(0);
127+
&(*y.borrow_mut());
128+
(&(0));
129+
(&(*y.borrow_mut()));
110130
let err: Value<i32> = Rc::new(RefCell::new(0));
111-
((*err.borrow_mut()) = 42);
131+
(&((*err.borrow_mut()) = 42));
112132
assert!(((*err.borrow()) == 42));
113133
let chosen: Value<i32> = Rc::new(RefCell::new({
114-
((*err.borrow_mut()) = 7);
134+
&((*err.borrow_mut()) = 7);
115135
123
116136
}));
117137
assert!(((*err.borrow()) == 7));
118138
assert!(((*chosen.borrow()) == 123));
119-
bump_and_return_4;
139+
&(bump_and_return_4);
120140
assert!(((*side_effect_counter_3.with(Value::clone).borrow()) == 2));
121-
(FnPtr::<fn() -> i32>::new(bump_and_return_4));
141+
&(FnPtr::<fn() -> i32>::new(bump_and_return_4));
122142
assert!(((*side_effect_counter_3.with(Value::clone).borrow()) == 2));
123-
((FnPtr::<fn() -> i32>::new(bump_and_return_4)).cast::<fn() -> i32>(None));
143+
&((FnPtr::<fn() -> i32>::new(bump_and_return_4)).cast::<fn() -> i32>(None));
124144
assert!(((*side_effect_counter_3.with(Value::clone).borrow()) == 2));
125145
let storage: Value<i32> = Rc::new(RefCell::new(11));
126146
let p: Value<Ptr<i32>> = Rc::new(RefCell::new((storage.as_pointer())));
127-
((*p.borrow()).read());
128-
(*p.borrow_mut()).clone();
147+
&((*p.borrow()).read());
148+
&(*p.borrow_mut());
129149
let arr: Value<Box<[i32]>> = Rc::new(RefCell::new(Box::new([1, 2, 3])));
130-
((*arr.borrow_mut())[(1) as usize]);
150+
&((*arr.borrow_mut())[(1) as usize]);
131151
let h: Value<Holder> = Rc::new(RefCell::new(Holder {
132152
field: Rc::new(RefCell::new(17)),
133153
}));
134-
(*(*h.borrow()).field.borrow_mut());
154+
&(*(*h.borrow()).field.borrow_mut());
135155
let hp: Value<Ptr<Holder>> = Rc::new(RefCell::new((h.as_pointer())));
136-
(*(*(*hp.borrow()).upgrade().deref()).field.borrow_mut());
156+
&(*(*(*hp.borrow()).upgrade().deref()).field.borrow_mut());
137157
let nt: Value<NonTrivial> = Rc::new(RefCell::new(<NonTrivial>::default()));
138158
({ unused_ref_param_1(nt.as_pointer()) });
139159
({ unused_ptr_param_2((nt.as_pointer())) });
160+
let g: Value<NonCopyable> = Rc::new(RefCell::new(NonCopyable {
161+
value: Rc::new(RefCell::new(Some(Rc::new(RefCell::new(9))))),
162+
}));
163+
(&(*g.borrow_mut()));
164+
&(*g.borrow_mut());
165+
({ unused_noncopyable_param_5(g.as_pointer()) });
166+
assert!(((*(*(*g.borrow()).value.borrow()).as_ref().unwrap().borrow()) == 9));
140167
return 0;
141168
}

0 commit comments

Comments
 (0)