about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/unsafe_sizeof_count_copies.rs42
-rw-r--r--clippy_lints/src/utils/paths.rs4
-rw-r--r--tests/ui/unsafe_sizeof_count_copies.rs12
-rw-r--r--tests/ui/unsafe_sizeof_count_copies.stderr122
4 files changed, 126 insertions, 54 deletions
diff --git a/clippy_lints/src/unsafe_sizeof_count_copies.rs b/clippy_lints/src/unsafe_sizeof_count_copies.rs
index 5df7d72564e..8a4538091e7 100644
--- a/clippy_lints/src/unsafe_sizeof_count_copies.rs
+++ b/clippy_lints/src/unsafe_sizeof_count_copies.rs
@@ -41,8 +41,8 @@ declare_clippy_lint! {
 declare_lint_pass!(UnsafeSizeofCountCopies => [UNSAFE_SIZEOF_COUNT_COPIES]);
 
 fn get_size_of_ty(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<Ty<'tcx>> {
-    match &expr.kind {
-        ExprKind::Call(ref count_func, _func_args) => {
+    match expr.kind {
+        ExprKind::Call(count_func, _func_args) => {
             if_chain! {
                 if let ExprKind::Path(ref count_func_qpath) = count_func.kind;
                 if let Some(def_id) = cx.qpath_res(count_func_qpath, count_func.hir_id).opt_def_id();
@@ -56,7 +56,7 @@ fn get_size_of_ty(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<Ty<'tc
             }
         },
         ExprKind::Binary(op, left, right) if BinOpKind::Mul == op.node || BinOpKind::Div == op.node => {
-            get_size_of_ty(cx, &*left).or_else(|| get_size_of_ty(cx, &*right))
+            get_size_of_ty(cx, left).or_else(|| get_size_of_ty(cx, right))
         },
         _ => None,
     }
@@ -64,13 +64,16 @@ fn get_size_of_ty(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<Ty<'tc
 
 fn get_pointee_ty_and_count_expr(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<(Ty<'tcx>, &'tcx Expr<'tcx>)> {
     if_chain! {
-        // Find calls to ptr::copy and copy_nonoverlapping
-        if let ExprKind::Call(ref func, ref args) = expr.kind;
-        if let [_src, _dest, count] = &**args;
+        // Find calls to ptr::{copy, copy_nonoverlapping}
+        // and ptr::{swap_nonoverlapping, write_bytes},
+        if let ExprKind::Call(func, args) = expr.kind;
+        if let [_, _, count] = args;
         if let ExprKind::Path(ref func_qpath) = func.kind;
         if let Some(def_id) = cx.qpath_res(func_qpath, func.hir_id).opt_def_id();
         if match_def_path(cx, def_id, &paths::COPY_NONOVERLAPPING)
-            || match_def_path(cx, def_id, &paths::COPY);
+            || match_def_path(cx, def_id, &paths::COPY)
+            || match_def_path(cx, def_id, &paths::WRITE_BYTES)
+            || match_def_path(cx, def_id, &paths::PTR_SWAP_NONOVERLAPPING);
 
         // Get the pointee type
         if let Some(pointee_ty) = cx.typeck_results().node_substs(func.hir_id).types().next();
@@ -79,11 +82,11 @@ fn get_pointee_ty_and_count_expr(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -
         }
     };
     if_chain! {
-        // Find calls to copy_{from,to}{,_nonoverlapping}
-        if let ExprKind::MethodCall(ref method_path, _, ref args, _) = expr.kind;
-        if let [ptr_self, _, count] = &**args;
+        // Find calls to copy_{from,to}{,_nonoverlapping} and write_bytes methods
+        if let ExprKind::MethodCall(method_path, _, args, _) = expr.kind;
+        if let [ptr_self, _, count] = args;
         let method_ident = method_path.ident.as_str();
-        if method_ident== "copy_to" || method_ident == "copy_from"
+        if method_ident == "write_bytes" || method_ident == "copy_to" || method_ident == "copy_from"
             || method_ident == "copy_to_nonoverlapping" || method_ident == "copy_from_nonoverlapping";
 
         // Get the pointee type
@@ -93,6 +96,21 @@ fn get_pointee_ty_and_count_expr(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -
             return Some((pointee_ty, count));
         }
     };
+    if_chain! {
+        // Find calls to ptr::copy and copy_nonoverlapping
+        if let ExprKind::Call(func, args) = expr.kind;
+        if let [_data, count] = args;
+        if let ExprKind::Path(ref func_qpath) = func.kind;
+        if let Some(def_id) = cx.qpath_res(func_qpath, func.hir_id).opt_def_id();
+        if match_def_path(cx, def_id, &paths::PTR_SLICE_FROM_RAW_PARTS)
+            || match_def_path(cx, def_id, &paths::PTR_SLICE_FROM_RAW_PARTS_MUT);
+
+        // Get the pointee type
+        if let Some(pointee_ty) = cx.typeck_results().node_substs(func.hir_id).types().next();
+        then {
+            return Some((pointee_ty, count));
+        }
+    };
     None
 }
 
@@ -102,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for UnsafeSizeofCountCopies {
             for the count parameter, it already gets multiplied by the size of the pointed to type";
 
         const LINT_MSG: &str = "unsafe memory copying using a byte count \
-            (Multiplied by size_of::<T>) instead of a count of T";
+            (multiplied by size_of/size_of_val::<T>) instead of a count of T";
 
         if_chain! {
             // Find calls to unsafe copy functions and get
diff --git a/clippy_lints/src/utils/paths.rs b/clippy_lints/src/utils/paths.rs
index fe763d4bfbb..87c020a99db 100644
--- a/clippy_lints/src/utils/paths.rs
+++ b/clippy_lints/src/utils/paths.rs
@@ -104,6 +104,9 @@ pub const POLL_READY: [&str; 5] = ["core", "task", "poll", "Poll", "Ready"];
 pub const PTR_EQ: [&str; 3] = ["core", "ptr", "eq"];
 pub const PTR_NULL: [&str; 3] = ["core", "ptr", "null"];
 pub const PTR_NULL_MUT: [&str; 3] = ["core", "ptr", "null_mut"];
+pub const PTR_SLICE_FROM_RAW_PARTS: [&str; 3] = ["core", "ptr", "slice_from_raw_parts"];
+pub const PTR_SLICE_FROM_RAW_PARTS_MUT: [&str; 3] = ["core", "ptr", "slice_from_raw_parts_mut"];
+pub const PTR_SWAP_NONOVERLAPPING: [&str; 3] = ["core", "ptr", "swap_nonoverlapping"];
 pub const PUSH_STR: [&str; 4] = ["alloc", "string", "String", "push_str"];
 pub const RANGE_ARGUMENT_TRAIT: [&str; 3] = ["core", "ops", "RangeBounds"];
 pub const RC: [&str; 3] = ["alloc", "rc", "Rc"];
@@ -158,3 +161,4 @@ pub const VEC_NEW: [&str; 4] = ["alloc", "vec", "Vec", "new"];
 pub const VEC_RESIZE: [&str; 4] = ["alloc", "vec", "Vec", "resize"];
 pub const WEAK_ARC: [&str; 3] = ["alloc", "sync", "Weak"];
 pub const WEAK_RC: [&str; 3] = ["alloc", "rc", "Weak"];
+pub const WRITE_BYTES: [&str; 3] = ["core", "intrinsics", "write_bytes"];
diff --git a/tests/ui/unsafe_sizeof_count_copies.rs b/tests/ui/unsafe_sizeof_count_copies.rs
index 0bb22314cc0..6aed8c31f7e 100644
--- a/tests/ui/unsafe_sizeof_count_copies.rs
+++ b/tests/ui/unsafe_sizeof_count_copies.rs
@@ -1,7 +1,9 @@
 #![warn(clippy::unsafe_sizeof_count_copies)]
 
 use std::mem::{size_of, size_of_val};
-use std::ptr::{copy, copy_nonoverlapping};
+use std::ptr::{
+    copy, copy_nonoverlapping, slice_from_raw_parts, slice_from_raw_parts_mut, swap_nonoverlapping, write_bytes,
+};
 
 fn main() {
     const SIZE: usize = 128;
@@ -22,6 +24,14 @@ fn main() {
     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>()) };
     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) };
 
+    unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::<u8>() * SIZE) };
+    unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::<u8>() * SIZE) };
+
+    unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::<u8>() * SIZE) };
+
+    unsafe { slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::<u8>() * SIZE) };
+    unsafe { slice_from_raw_parts(y.as_ptr(), size_of::<u8>() * SIZE) };
+
     // Count expression involving multiplication of size_of (Should trigger the lint)
     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * SIZE) };
diff --git a/tests/ui/unsafe_sizeof_count_copies.stderr b/tests/ui/unsafe_sizeof_count_copies.stderr
index 14ca04617c2..6f491bc4e4a 100644
--- a/tests/ui/unsafe_sizeof_count_copies.stderr
+++ b/tests/ui/unsafe_sizeof_count_copies.stderr
@@ -1,5 +1,5 @@
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:14:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:16:14
    |
 LL |     unsafe { copy_nonoverlapping::<u8>(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>()) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -7,157 +7,197 @@ LL |     unsafe { copy_nonoverlapping::<u8>(x.as_ptr(), y.as_mut_ptr(), size_of:
    = note: `-D clippy::unsafe-sizeof-count-copies` implied by `-D warnings`
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:15:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:17:14
    |
 LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:17:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:19:14
    |
 LL |     unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::<u8>()) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:18:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:20:14
    |
 LL |     unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of::<u8>()) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:19:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:21:14
    |
 LL |     unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::<u8>()) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:20:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:22:14
    |
 LL |     unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::<u8>()) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:22:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:24:14
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>()) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:23:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:25:14
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:26:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:27:14
+   |
+LL |     unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::<u8>() * SIZE) };
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
+
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:28:14
+   |
+LL |     unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::<u8>() * SIZE) };
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
+
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:30:14
+   |
+LL |     unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::<u8>() * SIZE) };
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
+
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:32:14
+   |
+LL |     unsafe { slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::<u8>() * SIZE) };
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
+
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:33:14
+   |
+LL |     unsafe { slice_from_raw_parts(y.as_ptr(), size_of::<u8>() * SIZE) };
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
+
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:36:14
    |
 LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:27:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:37:14
    |
 LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * SIZE) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:29:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:39:14
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:30:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:40:14
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * SIZE) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:33:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:43:14
    |
 LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * HALF_SIZE * 2) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:34:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:44:14
    |
 LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:36:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:46:14
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE * HALF_SIZE) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:37:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:47:14
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * HALF_SIZE * 2) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:40:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:50:14
    |
 LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * DOUBLE_SIZE / 2) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:41:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:51:14
    |
 LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / 2 * size_of_val(&x[0])) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:43:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:53:14
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::<u8>() / 2) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: unsafe memory copying using a byte count (Multiplied by size_of::<T>) instead of a count of T
-  --> $DIR/unsafe_sizeof_count_copies.rs:44:14
+error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
+  --> $DIR/unsafe_sizeof_count_copies.rs:54:14
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * DOUBLE_SIZE / 2) };
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes for the count parameter, it already gets multiplied by the size of the pointed to type
 
-error: aborting due to 20 previous errors
+error: aborting due to 25 previous errors