Skip to content

Commit db20fa3

Browse files
committed
Remove unnecessary unsafe_size_count_copies tests
1 parent d1da613 commit db20fa3

File tree

2 files changed

+3
-95
lines changed

2 files changed

+3
-95
lines changed

tests/ui/unsafe_sizeof_count_copies.rs

+1-21
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,16 @@ fn main() {
3434

3535
// Count expression involving multiplication of size_of (Should trigger the lint)
3636
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
37-
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * SIZE) };
38-
39-
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
40-
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * SIZE) };
4137

4238
// Count expression involving nested multiplications of size_of (Should trigger the lint)
43-
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * HALF_SIZE * 2) };
4439
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) };
4540

46-
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE * HALF_SIZE) };
47-
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * HALF_SIZE * 2) };
48-
4941
// Count expression involving divisions of size_of (Should trigger the lint)
50-
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * DOUBLE_SIZE / 2) };
51-
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / 2 * size_of_val(&x[0])) };
52-
5342
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::<u8>() / 2) };
54-
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * DOUBLE_SIZE / 2) };
5543

5644
// No size_of calls (Should not trigger the lint)
57-
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), SIZE) };
58-
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), SIZE) };
59-
60-
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), SIZE) };
6145
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), SIZE) };
6246

6347
// Different types for pointee and size_of (Should not trigger the lint)
64-
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u16>() / 2 * SIZE) };
65-
unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&0u16) / 2 * SIZE) };
66-
67-
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u16>() / 2 * SIZE) };
68-
unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&0u16) / 2 * SIZE) };
48+
unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::<u16>() / 2 * SIZE) };
6949
}

tests/ui/unsafe_sizeof_count_copies.stderr

+2-74
Original file line numberDiff line numberDiff line change
@@ -111,93 +111,21 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>(
111111
|
112112
= 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
113113

114-
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
115-
--> $DIR/unsafe_sizeof_count_copies.rs:37:14
116-
|
117-
LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * SIZE) };
118-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
119-
|
120-
= 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
121-
122114
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
123115
--> $DIR/unsafe_sizeof_count_copies.rs:39:14
124116
|
125-
LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
126-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127-
|
128-
= 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
129-
130-
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
131-
--> $DIR/unsafe_sizeof_count_copies.rs:40:14
132-
|
133-
LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * SIZE) };
134-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135-
|
136-
= 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
137-
138-
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
139-
--> $DIR/unsafe_sizeof_count_copies.rs:43:14
140-
|
141-
LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * HALF_SIZE * 2) };
142-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
143-
|
144-
= 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
145-
146-
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
147-
--> $DIR/unsafe_sizeof_count_copies.rs:44:14
148-
|
149117
LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) };
150118
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
151119
|
152120
= 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
153121

154122
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
155-
--> $DIR/unsafe_sizeof_count_copies.rs:46:14
156-
|
157-
LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE * HALF_SIZE) };
158-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
159-
|
160-
= 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
161-
162-
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
163-
--> $DIR/unsafe_sizeof_count_copies.rs:47:14
164-
|
165-
LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * HALF_SIZE * 2) };
166-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
167-
|
168-
= 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
169-
170-
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
171-
--> $DIR/unsafe_sizeof_count_copies.rs:50:14
172-
|
173-
LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * DOUBLE_SIZE / 2) };
174-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
175-
|
176-
= 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
177-
178-
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
179-
--> $DIR/unsafe_sizeof_count_copies.rs:51:14
180-
|
181-
LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / 2 * size_of_val(&x[0])) };
182-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
183-
|
184-
= 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
185-
186-
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
187-
--> $DIR/unsafe_sizeof_count_copies.rs:53:14
123+
--> $DIR/unsafe_sizeof_count_copies.rs:42:14
188124
|
189125
LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::<u8>() / 2) };
190126
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
191127
|
192128
= 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
193129

194-
error: unsafe memory copying using a byte count (multiplied by size_of/size_of_val::<T>) instead of a count of T
195-
--> $DIR/unsafe_sizeof_count_copies.rs:54:14
196-
|
197-
LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0]) * DOUBLE_SIZE / 2) };
198-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
199-
|
200-
= 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
201-
202-
error: aborting due to 25 previous errors
130+
error: aborting due to 16 previous errors
203131

0 commit comments

Comments
 (0)