Skip to content

Commit 6acbd45

Browse files
committed
Force copy for incomplete arrays.
1 parent 92a3086 commit 6acbd45

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/codegen/mod.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,31 +2385,48 @@ mod utils {
23852385

23862386
#[inline]
23872387
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
2388-
::std::slice::from_raw_parts(self.as_ptr(), len)
2388+
::$prefix::slice::from_raw_parts(self.as_ptr(), len)
23892389
}
23902390

23912391
#[inline]
23922392
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
2393-
::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
2393+
::$prefix::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
23942394
}
23952395
}
23962396
)
23972397
.unwrap();
23982398

23992399
let incomplete_array_debug_impl = quote_item!(ctx.ext_cx(),
2400-
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
2401-
fn fmt(&self, fmt: &mut ::std::fmt::Formatter)
2402-
-> ::std::fmt::Result {
2400+
impl<T> ::$prefix::fmt::Debug for __IncompleteArrayField<T> {
2401+
fn fmt(&self, fmt: &mut ::$prefix::fmt::Formatter)
2402+
-> ::$prefix::fmt::Result {
24032403
fmt.write_str("__IncompleteArrayField")
24042404
}
24052405
}
24062406
)
24072407
.unwrap();
24082408

2409+
let incomplete_array_clone_impl = quote_item!(&ctx.ext_cx(),
2410+
impl<T> ::$prefix::clone::Clone for __IncompleteArrayField<T> {
2411+
#[inline]
2412+
fn clone(&self) -> Self {
2413+
Self::new()
2414+
}
2415+
}
2416+
)
2417+
.unwrap();
2418+
2419+
let incomplete_array_copy_impl = quote_item!(&ctx.ext_cx(),
2420+
impl<T> ::$prefix::marker::Copy for __IncompleteArrayField<T> {}
2421+
)
2422+
.unwrap();
2423+
24092424
let items = vec![
24102425
incomplete_array_decl,
24112426
incomplete_array_impl,
24122427
incomplete_array_debug_impl,
2428+
incomplete_array_clone_impl,
2429+
incomplete_array_copy_impl,
24132430
];
24142431

24152432
let old_items = mem::replace(result, items);

0 commit comments

Comments
 (0)