Skip to content

Commit 4fc5607

Browse files
committed
Update tests
1 parent 4f4ecc6 commit 4fc5607

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ impl Container {
8080
}
8181
}
8282
}
83+
#[derive(Record, ByteRepr, FnPtrArg, MoveCtor, Default)]
84+
#[byte_size(24)]
85+
pub struct VecHolder {
86+
#[offset(0)]
87+
#[byte_size(24)]
88+
pub items: Vec<NoCopy>,
89+
}
90+
impl VecHolder {
91+
pub fn move_from(_a0: Ptr<VecHolder>) -> Self {
92+
Self {
93+
items: field!(_a0, items).with_mut(std::mem::take),
94+
}
95+
}
96+
}
8397
pub fn bump_0(mut p: Ptr<NoCopy>) {
8498
field!(p, v).with_mut(|__v| __v.postfix_inc());
8599
}
@@ -115,6 +129,9 @@ fn main_0() -> i32 {
115129
}));
116130
let mut d: Container = Container::move_from({ c.as_pointer() });
117131
assert!(((d.inner.v == 6) && (d.tag == 7)) && ({ (*c.borrow()).inner.v } == 0));
132+
let h: Value<VecHolder> = Rc::new(RefCell::new(<VecHolder>::default()));
133+
let mut h2: VecHolder = VecHolder::move_from({ h.as_pointer() });
134+
assert!((h2.items.len() == 0_usize));
118135
return 0;
119136
}
120137
pub trait ContainerImpl {

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ impl Container {
9292
return &mut (*(self as *mut Container));
9393
}
9494
}
95+
#[repr(C)]
96+
#[derive(FnPtrArg, MoveCtorUnsafe, Default)]
97+
pub struct VecHolder {
98+
pub items: Vec<NoCopy>,
99+
}
100+
impl VecHolder {
101+
pub unsafe fn move_from(_a0: *mut VecHolder) -> Self {
102+
let mut this = Self {
103+
items: std::mem::take(&mut (*_a0).items),
104+
};
105+
this
106+
}
107+
}
95108
pub unsafe fn bump_0(mut p: *mut NoCopy) {
96109
(*p).v.postfix_inc();
97110
}
@@ -129,6 +142,9 @@ unsafe fn main_0() -> i32 {
129142
};
130143
let mut d: Container = Container::move_from({ &mut c });
131144
assert!((((d.inner.v) == (6)) && ((d.tag) == (7))) && ((c.inner.v) == (0)));
145+
let mut h: VecHolder = <VecHolder>::default();
146+
let mut h2: VecHolder = VecHolder::move_from({ &mut h });
147+
assert!(((h2.items.len()) == (0_usize)));
132148
return 0;
133149
}
134150
pub unsafe fn __cpp2rust_init_globals() {}

0 commit comments

Comments
 (0)