Skip to content

Commit dbb61ac

Browse files
committed
Update tests
1 parent 2b6d740 commit dbb61ac

36 files changed

Lines changed: 406 additions & 206 deletions

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9-
#[derive(Default)]
9+
#[derive(Clone, Default)]
1010
pub struct S {
1111
pub r: Ptr<i32>,
1212
}
@@ -17,15 +17,6 @@ impl S {
1717
Rc::try_unwrap(__this).ok().unwrap().into_inner()
1818
}
1919
}
20-
impl Clone for S {
21-
fn clone(&self) -> Self {
22-
let __this: Value<S> = Rc::new(RefCell::new(Self {
23-
r: (self.r).clone(),
24-
}));
25-
let this: Ptr<S> = __this.as_pointer();
26-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
27-
}
28-
}
2920
impl ByteRepr for S {}
3021
pub fn main() {
3122
__cpp2rust_init_globals();

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,11 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9-
#[derive(Default)]
9+
#[derive(Clone, Default)]
1010
pub struct Pair {
1111
pub x1: Ptr<i32>,
1212
pub x2: Ptr<i32>,
1313
}
14-
impl Clone for Pair {
15-
fn clone(&self) -> Self {
16-
let __this: Value<Pair> = Rc::new(RefCell::new(Self {
17-
x1: (self.x1).clone(),
18-
x2: (self.x2).clone(),
19-
}));
20-
let this: Ptr<Pair> = __this.as_pointer();
21-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
22-
}
23-
}
2414
impl ByteRepr for Pair {}
2515
pub fn mkPair_0(x1: Ptr<i32>, x2: Ptr<i32>) -> Pair {
2616
return Pair {

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,10 @@ impl ByteRepr for X1 {
4343
}
4444
}
4545
}
46-
#[derive(Default)]
46+
#[derive(Clone, Default)]
4747
pub struct X2 {
4848
pub v: Ptr<X1>,
4949
}
50-
impl Clone for X2 {
51-
fn clone(&self) -> Self {
52-
let __this: Value<X2> = Rc::new(RefCell::new(Self {
53-
v: (self.v).clone(),
54-
}));
55-
let this: Ptr<X2> = __this.as_pointer();
56-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
57-
}
58-
}
5950
impl ByteRepr for X2 {}
6051
#[derive(Default)]
6152
pub struct X3 {

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ use std::rc::{Rc, Weak};
99
thread_local!(
1010
pub static global_0: Value<i32> = Rc::new(RefCell::new(0));
1111
);
12-
#[derive(Default)]
12+
#[derive(Clone, Default)]
1313
pub struct S {}
14-
impl Clone for S {
15-
fn clone(&self) -> Self {
16-
let __this: Value<S> = Rc::new(RefCell::new(Self {}));
17-
let this: Ptr<S> = __this.as_pointer();
18-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
19-
}
20-
}
2114
impl ByteRepr for S {
2215
fn byte_size() -> usize {
2316
1

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,36 @@ fn main_0() -> i32 {
2727
assert!((({ apply_1(5, None,) }) == 5));
2828
assert!((({ apply_1(5, Some(FnPtr::<fn(i32) -> i32>::null()),) }) == 5));
2929
assert!((({ apply_1(5, Some(FnPtr::<fn(i32) -> i32>::new(identity_0)),) }) == 5));
30-
let negate: Value<FnPtr<fn(i32) -> i32>> = Rc::new(RefCell::new(FnPtr::new(
31-
(|x: i32| {
32-
let x: Value<i32> = Rc::new(RefCell::new(x));
33-
return -(*x.borrow());
34-
}),
35-
)));
30+
let negate: Value<FnPtr<fn(i32) -> i32>> =
31+
Rc::new(RefCell::new(({ (lambda_2 {}).to_free_function() })));
3632
assert!((({ apply_1(5, Some((*negate.borrow()).clone()),) }) == -5_i32));
3733
return 0;
3834
}
35+
#[derive(Clone, Default)]
36+
pub struct lambda_2 {}
37+
impl lambda_2 {
38+
pub fn operator_call(x: i32) -> i32 {
39+
let x: Value<i32> = Rc::new(RefCell::new(x));
40+
return -(*x.borrow());
41+
}
42+
}
43+
impl ByteRepr for lambda_2 {
44+
fn byte_size() -> usize {
45+
1
46+
}
47+
fn to_bytes(&self, buf: &mut [u8]) {}
48+
fn from_bytes(buf: &[u8]) -> Self {
49+
Self {}
50+
}
51+
}
52+
impl Callable1<i32, i32> for lambda_2 {
53+
fn call(&self, a1: i32) -> i32 {
54+
{ lambda_2::operator_call(a1) }
55+
}
56+
}
57+
impl lambda_2 {
58+
pub fn to_free_function(&self) -> FnPtr<fn(i32) -> i32> {
59+
FnPtr::new(lambda_2::operator_call)
60+
}
61+
}
3962
pub fn __cpp2rust_init_globals() {}

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,8 @@ pub fn foo_3(x: Ptr<i32>, y: Ptr<i32>, z: Ptr<i32>) -> i32 {
3636
pub fn bar_4(x: Ptr<i32>) -> i32 {
3737
return (x.read());
3838
}
39-
#[derive(Default)]
39+
#[derive(Clone, Default)]
4040
pub struct Foo {}
41-
impl Clone for Foo {
42-
fn clone(&self) -> Self {
43-
let __this: Value<Foo> = Rc::new(RefCell::new(Self {}));
44-
let this: Ptr<Foo> = __this.as_pointer();
45-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
46-
}
47-
}
4841
impl ByteRepr for Foo {
4942
fn byte_size() -> usize {
5043
1

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::rc::{Rc, Weak};
99
thread_local!(
1010
pub static total_0: Value<i32> = Rc::new(RefCell::new(0));
1111
);
12-
#[derive(Default)]
12+
#[derive(Clone, Default)]
1313
pub struct S {}
1414
impl S {
1515
pub fn S(x: i32) -> Self {
@@ -20,13 +20,6 @@ impl S {
2020
Rc::try_unwrap(__this).ok().unwrap().into_inner()
2121
}
2222
}
23-
impl Clone for S {
24-
fn clone(&self) -> Self {
25-
let __this: Value<S> = Rc::new(RefCell::new(Self {}));
26-
let this: Ptr<S> = __this.as_pointer();
27-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
28-
}
29-
}
3023
impl ByteRepr for S {
3124
fn byte_size() -> usize {
3225
1

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,8 @@ thread_local!(
9999
thread_local!(
100100
pub static inline_member_11: Value<Ctor> = Rc::new(RefCell::new(Ctor::Ctor2({ 5 })));
101101
);
102-
#[derive(Default)]
102+
#[derive(Clone, Default)]
103103
pub struct Holder {}
104-
impl Clone for Holder {
105-
fn clone(&self) -> Self {
106-
let __this: Value<Holder> = Rc::new(RefCell::new(Self {}));
107-
let this: Ptr<Holder> = __this.as_pointer();
108-
Rc::try_unwrap(__this).ok().unwrap().into_inner()
109-
}
110-
}
111104
impl ByteRepr for Holder {
112105
fn byte_size() -> usize {
113106
1

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub fn apply_twice_6(fn_: lambda_3, x: i32) -> i32 {
3030
});
3131
}
3232
pub fn main() {
33+
__cpp2rust_init_globals();
3334
std::process::exit(main_0());
3435
}
3536
fn main_0() -> i32 {
@@ -131,3 +132,4 @@ impl lambda_5 {
131132
FnPtr::new(lambda_5::operator_call)
132133
}
133134
}
135+
pub fn __cpp2rust_init_globals() {}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn main() {
10+
__cpp2rust_init_globals();
1011
std::process::exit(main_0());
1112
}
1213
fn main_0() -> i32 {
@@ -157,3 +158,4 @@ impl Callable0<i32> for lambda_4 {
157158
{ lambda_4::operator_call(self) }
158159
}
159160
}
161+
pub fn __cpp2rust_init_globals() {}

0 commit comments

Comments
 (0)