Skip to content

Commit e339ed8

Browse files
committed
Update tests
1 parent 36592c4 commit e339ed8

8 files changed

Lines changed: 58 additions & 19 deletions

File tree

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

Lines changed: 8 additions & 1 deletion
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()]
1010
pub struct S_int_ {
1111
pub x: Value<i32>,
1212
}
@@ -19,6 +19,13 @@ impl Clone for S_int_ {
1919
Rc::try_unwrap(__this).ok().unwrap().into_inner()
2020
}
2121
}
22+
impl Default for S_int_ {
23+
fn default() -> Self {
24+
S_int_ {
25+
x: Rc::new(RefCell::new(0)),
26+
}
27+
}
28+
}
2229
impl ByteRepr for S_int_ {
2330
fn byte_size() -> usize {
2431
4

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

Lines changed: 6 additions & 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, Default)]
10+
#[derive(Copy, Clone)]
1111
pub struct S_int_ {
1212
pub x: i32,
1313
}
@@ -16,6 +16,11 @@ impl S_int_ {
1616
self.x = v;
1717
}
1818
}
19+
impl Default for S_int_ {
20+
fn default() -> Self {
21+
S_int_ { x: 0 }
22+
}
23+
}
1924
pub fn main() {
2025
unsafe {
2126
__cpp2rust_init_globals();

‎tests/unit/out/refcount/10_struct.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl ByteRepr for Graph {
6666
}
6767
}
6868
}
69-
#[derive(Default)]
69+
#[derive()]
7070
pub struct Partial {
7171
pub p: Value<Ptr<i32>>,
7272
}
@@ -89,6 +89,13 @@ impl Clone for Partial {
8989
Rc::try_unwrap(__this).ok().unwrap().into_inner()
9090
}
9191
}
92+
impl Default for Partial {
93+
fn default() -> Self {
94+
Partial {
95+
p: Rc::new(RefCell::new(Ptr::<i32>::null())),
96+
}
97+
}
98+
}
9299
impl ByteRepr for Partial {
93100
fn byte_size() -> usize {
94101
8

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ pub struct NonCopy {
1313
}
1414
impl Clone for NonCopy {
1515
fn clone(&self) -> Self {
16-
let mut this = Self {
16+
let __this: Value<NonCopy> = Rc::new(RefCell::new(Self {
1717
data: Rc::new(RefCell::new((*self.data.borrow()).clone())),
1818
tag: Rc::new(RefCell::new((*self.tag.borrow()))),
19-
};
20-
this
19+
}));
20+
let this: Ptr<NonCopy> = __this.as_pointer();
21+
Rc::try_unwrap(__this).ok().unwrap().into_inner()
2122
}
2223
}
2324
impl Default for NonCopy {
@@ -44,6 +45,7 @@ impl ByteRepr for NonCopy {
4445
}
4546
}
4647
pub fn main() {
48+
__cpp2rust_init_globals();
4749
std::process::exit(main_0());
4850
}
4951
fn main_0() -> i32 {
@@ -66,3 +68,4 @@ fn main_0() -> i32 {
6668
assert!(((*(*arr.borrow())[(2) as usize].data.borrow()).len() == 0_usize));
6769
return 0;
6870
}
71+
pub fn __cpp2rust_init_globals() {}

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ pub struct Inner {
1313
}
1414
impl Clone for Inner {
1515
fn clone(&self) -> Self {
16-
let mut this = Self {
16+
let __this: Value<Inner> = Rc::new(RefCell::new(Self {
1717
x: Rc::new(RefCell::new((*self.x.borrow()))),
1818
y: Rc::new(RefCell::new((*self.y.borrow()))),
19-
};
20-
this
19+
}));
20+
let this: Ptr<Inner> = __this.as_pointer();
21+
Rc::try_unwrap(__this).ok().unwrap().into_inner()
2122
}
2223
}
2324
impl Default for Inner {
@@ -52,13 +53,14 @@ pub struct S {
5253
}
5354
impl Clone for S {
5455
fn clone(&self) -> Self {
55-
let mut this = Self {
56+
let __this: Value<S> = Rc::new(RefCell::new(Self {
5657
a: Rc::new(RefCell::new((*self.a.borrow()))),
5758
b: Rc::new(RefCell::new((*self.b.borrow()))),
5859
c: Rc::new(RefCell::new((*self.c.borrow()).clone())),
5960
d: Rc::new(RefCell::new((*self.d.borrow()).clone())),
60-
};
61-
this
61+
}));
62+
let this: Ptr<S> = __this.as_pointer();
63+
Rc::try_unwrap(__this).ok().unwrap().into_inner()
6264
}
6365
}
6466
impl Default for S {
@@ -102,20 +104,22 @@ impl Boxed_int_ {
102104
pub fn Boxed_int_(x: i32, t: i32) -> Self {
103105
let x: Value<i32> = Rc::new(RefCell::new(x));
104106
let t: Value<i32> = Rc::new(RefCell::new(t));
105-
let mut this = Self {
107+
let __this: Value<Boxed_int_> = Rc::new(RefCell::new(Self {
106108
v: Rc::new(RefCell::new((*x.borrow()))),
107109
tag: Rc::new(RefCell::new((*t.borrow()))),
108-
};
109-
this
110+
}));
111+
let this: Ptr<Boxed_int_> = __this.as_pointer();
112+
Rc::try_unwrap(__this).ok().unwrap().into_inner()
110113
}
111114
}
112115
impl Clone for Boxed_int_ {
113116
fn clone(&self) -> Self {
114-
let mut this = Self {
117+
let __this: Value<Boxed_int_> = Rc::new(RefCell::new(Self {
115118
v: Rc::new(RefCell::new((*self.v.borrow()))),
116119
tag: Rc::new(RefCell::new((*self.tag.borrow()))),
117-
};
118-
this
120+
}));
121+
let this: Ptr<Boxed_int_> = __this.as_pointer();
122+
Rc::try_unwrap(__this).ok().unwrap().into_inner()
119123
}
120124
}
121125
impl Default for Boxed_int_ {
@@ -142,6 +146,7 @@ impl ByteRepr for Boxed_int_ {
142146
}
143147
}
144148
pub fn main() {
149+
__cpp2rust_init_globals();
145150
std::process::exit(main_0());
146151
}
147152
fn main_0() -> i32 {
@@ -157,3 +162,4 @@ fn main_0() -> i32 {
157162
assert!(((*(*boxed.borrow()).tag.borrow()) == 9));
158163
return 0;
159164
}
165+
pub fn __cpp2rust_init_globals() {}

‎tests/unit/out/unsafe/10_struct.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Graph {
3131
}
3232
}
3333
#[repr(C)]
34-
#[derive(Copy, Clone, Default)]
34+
#[derive(Copy, Clone)]
3535
pub struct Partial {
3636
pub p: *mut i32,
3737
}
@@ -41,6 +41,13 @@ impl Partial {
4141
this
4242
}
4343
}
44+
impl Default for Partial {
45+
fn default() -> Self {
46+
Partial {
47+
p: std::ptr::null_mut(),
48+
}
49+
}
50+
}
4451
#[repr(C)]
4552
#[derive(Copy, Clone, Default)]
4653
pub struct Declared {}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ impl Default for NonCopy {
2222
}
2323
pub fn main() {
2424
unsafe {
25+
__cpp2rust_init_globals();
2526
std::process::exit(main_0() as i32);
2627
}
2728
}
@@ -36,3 +37,4 @@ unsafe fn main_0() -> i32 {
3637
assert!(((arr[(2) as usize].data.len()) == (0_usize)));
3738
return 0;
3839
}
40+
pub unsafe fn __cpp2rust_init_globals() {}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl Default for Boxed_int_ {
5757
}
5858
pub fn main() {
5959
unsafe {
60+
__cpp2rust_init_globals();
6061
std::process::exit(main_0() as i32);
6162
}
6263
}
@@ -73,3 +74,4 @@ unsafe fn main_0() -> i32 {
7374
assert!(((boxed.tag) == (9)));
7475
return 0;
7576
}
77+
pub unsafe fn __cpp2rust_init_globals() {}

0 commit comments

Comments
 (0)