Skip to content

Commit ad249f1

Browse files
committed
Add correct generated output for union_basic
1 parent dd535c6 commit ad249f1

2 files changed

Lines changed: 7 additions & 31 deletions

File tree

tests/unit/out/refcount/union_basic.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,20 @@ 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)]
910
pub struct basic {
10-
__buf: Rc<RefCell<Vec<u8>>>,
1111
pub i: Value<i32>,
1212
pub f: Value<f32>,
1313
}
14-
impl Default for basic {
15-
fn default() -> Self {
16-
let __buf = Rc::new(RefCell::new(vec![0u8; 4]));
17-
Self {
18-
__buf: __buf.clone(),
19-
i: Value::new_reinterpreted(
20-
Rc::new(SliceOriginalAlloc {
21-
weak: Rc::downgrade(&__buf),
22-
}),
23-
0,
24-
),
25-
f: Value::new_reinterpreted(
26-
Rc::new(SliceOriginalAlloc {
27-
weak: Rc::downgrade(&__buf),
28-
}),
29-
0,
30-
),
31-
}
32-
}
33-
}
3414
impl ByteRepr for basic {}
3515
pub fn main() {
3616
std::process::exit(main_0());
3717
}
3818
fn main_0() -> i32 {
3919
let u: Value<basic> = <Value<basic>>::default();
40-
(*u.borrow()).i.write(42);
41-
assert!(((*u.borrow()).i.read() == 42));
42-
(*u.borrow()).f.write(3.140000105E+0);
43-
assert!(((*u.borrow()).f.read() == 3.140000105E+0));
20+
(*(*u.borrow()).i.borrow_mut()) = 42;
21+
assert!(((*(*u.borrow()).i.borrow()) == 42));
22+
(*(*u.borrow()).f.borrow_mut()) = 3.140000105E+0;
23+
assert!(((*(*u.borrow()).f.borrow()) == 3.140000105E+0));
4424
return 0;
4525
}

tests/unit/out/unsafe/union_basic.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ use std::collections::BTreeMap;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
9-
pub union basic {
9+
#[derive(Copy, Clone, Default)]
10+
pub struct basic {
1011
pub i: i32,
1112
pub f: f32,
1213
}
13-
impl Default for basic {
14-
fn default() -> Self {
15-
unsafe { ::std::mem::MaybeUninit::zeroed().assume_init() }
16-
}
17-
}
1814
pub fn main() {
1915
unsafe {
2016
std::process::exit(main_0() as i32);

0 commit comments

Comments
 (0)