Skip to content

Commit d799e95

Browse files
committed
Update tests
1 parent 4951261 commit d799e95

42 files changed

Lines changed: 1552 additions & 687 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎tests/ub/out/refcount/ub6.rs‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,22 @@ pub fn fill_1(arr: Ptr<Option<Value<Box<[Ptr<i32>]>>>>, n1: Ptr<i32>) {
3131
mkPair_0(_x1, _x2)
3232
}),
3333
));
34-
(*arr.upgrade().deref()).as_ref().unwrap().borrow_mut()[(0_usize) as usize] =
35-
({ (*pair.borrow()).x1.clone() }).clone();
36-
(*arr.upgrade().deref()).as_ref().unwrap().borrow_mut()[(1_usize) as usize] =
37-
({ (*pair.borrow()).x2.clone() }).clone();
34+
((*arr.upgrade().deref()).as_pointer() as Ptr<Ptr<i32>>)
35+
.offset(0_usize as isize)
36+
.write(({ (*pair.borrow()).x1.clone() }).clone());
37+
((*arr.upgrade().deref()).as_pointer() as Ptr<Ptr<i32>>)
38+
.offset(1_usize as isize)
39+
.write(({ (*pair.borrow()).x2.clone() }).clone());
3840
}
3941
pub fn any_2(arr: Ptr<Option<Value<Box<[Ptr<i32>]>>>>, n1: Ptr<i32>) -> bool {
4042
let mut out: bool = false;
4143
let mut i: i32 = 0;
4244
'loop_: while ({ i } < { (n1.read()) }) {
4345
let __rhs = (out)
44-
|| (((*arr.upgrade().deref()).as_ref().unwrap().borrow()[(i as usize) as usize]
46+
|| (((((*arr.upgrade().deref()).as_pointer() as Ptr<Ptr<i32>>)
47+
.offset((i as usize) as isize)
4548
.read())
49+
.read())
4650
== 0);
4751
out = __rhs;
4852
i.prefix_inc();

‎tests/ub/out/unsafe/ub6.rs‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,25 @@ pub unsafe fn fill_1(arr: *mut Option<Box<[*mut i32]>>, n1: *mut i32) {
2222
let _x2: *mut i32 = &mut n2;
2323
mkPair_0(_x1, _x2)
2424
});
25-
(*arr).as_mut().unwrap()[(0_usize)] = (pair.x1);
26-
(*arr).as_mut().unwrap()[(1_usize)] = (pair.x2);
25+
(*(*arr)
26+
.as_deref()
27+
.map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut *mut i32)
28+
.add(0_usize)) = (pair.x1);
29+
(*(*arr)
30+
.as_deref()
31+
.map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut *mut i32)
32+
.add(1_usize)) = (pair.x2);
2733
}
2834
pub unsafe fn any_2(arr: *mut Option<Box<[*mut i32]>>, n1: *mut i32) -> bool {
2935
let mut out: bool = false;
3036
let mut i: i32 = 0;
3137
'loop_: while ((i) < (*n1)) {
32-
out = (out) || ((*(*arr).as_mut().unwrap()[(i as usize)]) == (0));
38+
out = (out)
39+
|| ((*(*(*arr)
40+
.as_deref()
41+
.map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut *mut i32)
42+
.add((i as usize))))
43+
== (0));
3344
i.prefix_inc();
3445
}
3546
return out;

‎tests/unit/out/refcount/07_unique.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn fn_0(mut u: Option<Value<i32>>) -> Option<Value<i32>> {
10-
(*u.as_ref().unwrap().borrow_mut()) = 10;
10+
u.as_pointer().write(10);
1111
return u.take();
1212
}
1313
pub fn main() {
@@ -16,14 +16,14 @@ pub fn main() {
1616
}
1717
fn main_0() -> i32 {
1818
let f: Value<Option<Value<i32>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new(8)))));
19-
(*(*f.borrow()).as_ref().unwrap().borrow_mut()) = 9;
19+
(*f.borrow()).as_pointer().write(9);
2020
let mut f_ptr1: Ptr<i32> = (*f.borrow()).as_pointer();
2121
f_ptr1.write(10);
2222
let mut f_ptr2: Ptr<i32> = ((*f.borrow()).as_pointer());
2323
f_ptr2.write(11);
2424
(f.as_pointer() as Ptr<Option<Value<i32>>>).write(Some(Rc::new(RefCell::new(9))).take());
2525
(f.as_pointer() as Ptr<Option<Value<i32>>>).write(({ fn_0((*f.borrow_mut()).take()) }).take());
26-
assert!(((*(*f.borrow()).as_ref().unwrap().borrow()) == 10));
26+
assert!((((*f.borrow()).as_pointer().read()) == 10));
2727
return 0;
2828
}
2929
pub fn __cpp2rust_init_globals() {}

‎tests/unit/out/refcount/08_unique_array.rs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ fn main_0() -> i32 {
1414
let mut g: Option<Value<Box<[i32]>>> = Some(Rc::new(RefCell::new(
1515
(0..2_usize).map(|_| <i32>::default()).collect::<Box<[_]>>(),
1616
)));
17-
g.as_ref().unwrap().borrow_mut()[(0_usize) as usize] = 11;
18-
g.as_ref().unwrap().borrow_mut()[(1_usize) as usize] = 12;
17+
(g.as_pointer() as Ptr<i32>)
18+
.offset(0_usize as isize)
19+
.write(11);
20+
(g.as_pointer() as Ptr<i32>)
21+
.offset(1_usize as isize)
22+
.write(12);
1923
let mut g_ptr: Ptr<i32> = g.as_pointer();
2024
elem!(g_ptr, 0).write(13);
2125
elem!(g_ptr, 1).write(14);
2226
assert!(
23-
((g.as_ref().unwrap().borrow()[(0_usize) as usize]
24-
+ g.as_ref().unwrap().borrow()[(1_usize) as usize])
27+
((((g.as_pointer() as Ptr<i32>).offset(0_usize as isize).read())
28+
+ ((g.as_pointer() as Ptr<i32>).offset(1_usize as isize).read()))
2529
== 27)
2630
);
2731
return 0;

‎tests/unit/out/refcount/11_move.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn main() {
1818
fn main_0() -> i32 {
1919
let n: Value<Option<Value<i32>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new(10)))));
2020
({ change_0(n.as_pointer()) });
21-
assert!(((*(*n.borrow()).as_ref().unwrap().borrow()) == 20));
21+
assert!((((*n.borrow()).as_pointer().read()) == 20));
2222
return 0;
2323
}
2424
pub fn __cpp2rust_init_globals() {}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ pub fn All_0(arr: Ptr<Option<Value<Box<[i32]>>>>, mut N: i32, mut element: i32)
1414
)))));
1515
let mut i: i32 = 0;
1616
'loop_: while (i < N) {
17-
(*all.borrow()).as_ref().unwrap().borrow_mut()[(i as usize) as usize] = element;
17+
((*all.borrow()).as_pointer() as Ptr<i32>)
18+
.offset((i as usize) as isize)
19+
.write(element);
1820
i.prefix_inc();
1921
}
2022
((arr).clone() as Ptr<Option<Value<Box<[i32]>>>>).write((*all.borrow_mut()).take());
@@ -23,7 +25,9 @@ pub fn Consume_1(mut arr: Option<Value<Box<[i32]>>>, mut N: i32) -> i32 {
2325
let mut sum: i32 = 0;
2426
let mut i: i32 = -1_i32;
2527
'loop_: while (i.prefix_inc() < N) {
26-
sum += arr.as_ref().unwrap().borrow()[(i as usize) as usize];
28+
sum += ((arr.as_pointer() as Ptr<i32>)
29+
.offset((i as usize) as isize)
30+
.read());
2731
}
2832
return sum;
2933
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ fn main_0() -> i32 {
379379
assert!(
380380
((({ (*o2.borrow()).n } == 5) && ((*o2.borrow()).data.len() == 1_usize))
381381
&& ((array_elem!(o2.as_pointer(), arr, 1).read()) == 6))
382-
&& ((*{ (*o2.borrow()).p.clone() }.as_ref().unwrap().borrow()) == 7)
382+
&& (({ (*o2.borrow()).p.clone() }.as_pointer().read()) == 7)
383383
);
384384
assert!(
385385
((*o1.borrow()).data.is_empty()) && (({ (*o1.borrow()).p.clone() }.as_pointer()).is_null())
@@ -390,7 +390,7 @@ fn main_0() -> i32 {
390390
((({ (*o3.borrow()).n } == 5)
391391
&& ((vec_elem!(o3.as_pointer(), data, 0_usize).read()) == 5))
392392
&& ((array_elem!(o3.as_pointer(), arr, 0).read()) == 5))
393-
&& ((*{ (*o3.borrow()).p.clone() }.as_ref().unwrap().borrow()) == 7)
393+
&& (({ (*o3.borrow()).p.clone() }.as_pointer().read()) == 7)
394394
);
395395
assert!(
396396
((*o2.borrow()).data.is_empty()) && (({ (*o2.borrow()).p.clone() }.as_pointer()).is_null())
@@ -405,7 +405,7 @@ fn main_0() -> i32 {
405405
let _dtor_h2 = ScopedDestructor::new(&h2, |__p| __p.destructor());
406406
assert!(
407407
((({ (*h2.borrow()).inner.x } == 4) && ({ (*h2.borrow()).e.v } == 4))
408-
&& ((*{ (*h2.borrow()).p.clone() }.as_ref().unwrap().borrow()) == 9))
408+
&& (({ (*h2.borrow()).p.clone() }.as_pointer().read()) == 9))
409409
&& (({ (*h1.borrow()).p.clone() }.as_pointer()).is_null())
410410
);
411411
let h3: Value<Holder> = Rc::new(RefCell::new(Holder::new({ 1 })));
@@ -414,7 +414,7 @@ fn main_0() -> i32 {
414414
assert!(
415415
((({ (*h3.borrow()).inner.x } == 4)
416416
&& ((array_elem!(field_ptr!(h3.as_pointer(), e), arr, 1).read()) == 5))
417-
&& ((*{ (*h3.borrow()).p.clone() }.as_ref().unwrap().borrow()) == 9))
417+
&& (({ (*h3.borrow()).p.clone() }.as_pointer().read()) == 9))
418418
&& (({ (*h2.borrow()).p.clone() }.as_pointer()).is_null())
419419
);
420420
return 0;

0 commit comments

Comments
 (0)