Remove unnecessary unsafe_size_count_copies tests

This commit is contained in:
unknown 2020-11-29 14:32:11 -03:00
parent 1b80990fe0
commit 63a3c44060
2 changed files with 3 additions and 95 deletions

View file

@ -34,36 +34,16 @@ fn main() {
// 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) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * SIZE) };
// Count expression involving nested multiplications of size_of (Should trigger the lint)
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * HALF_SIZE * 2) };
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE * HALF_SIZE) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * HALF_SIZE * 2) };
// Count expression involving divisions of size_of (Should trigger the lint)
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * DOUBLE_SIZE / 2) };
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / 2 * size_of_val(&x[0])) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::<u8>() / 2) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * DOUBLE_SIZE / 2) };
// No size_of calls (Should not trigger the lint)
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), SIZE) };
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), SIZE) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), SIZE) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), SIZE) };
// Different types for pointee and size_of (Should not trigger the lint)
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u16>() / 2 * SIZE) };
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&0u16) / 2 * SIZE) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u16>() / 2 * SIZE) };
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&0u16) / 2 * SIZE) };
unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::<u16>() / 2 * SIZE) };
}

View file

@ -111,93 +111,21 @@ LL | unsafe { copy_nonoverlapping(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/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/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/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/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/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/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/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/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/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/size_of_val::<T>) instead of a count of T
--> $DIR/unsafe_sizeof_count_copies.rs:53:14
--> $DIR/unsafe_sizeof_count_copies.rs:42: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/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 25 previous errors
error: aborting due to 16 previous errors