-
Notifications
You must be signed in to change notification settings - Fork 142
Description
We use the trybuild crate to test that zerocopy-derive correctly rejects code that it ought to. We have the same running for zerocopy itself, but no tests have been written to make use of it. zerocopy's API uses trait bounds to make certain illegal code impossible to express; we should write trybuild tests that make sure that each illegal code pattern actually fails to compile.
Contributing
If you'd like to contribute to this issue, just look through zerocopy's API, find unsound behavior that ought to be impossible to express, and write a test to confirm that it's inexpressible!
If you're not sure where to start, consider:
- Does the API have any documented preconditions which ought to be enforced at compile time?
- Does the API have any trait bounds?
Write a test which fails to uphold one of these requirements.
Here's a list of all of the APIs in zerocopy that have preconditions or trait bounds:
FromBytes(@IsaacCloos assigned)-
read_from -
read_from_prefix -
read_from_suffix
-
AsBytes-
as_bytes_mut -
write_to -
write_to_prefix -
write_to_suffix
-
LayoutVerified-
new -
new_from_prefix -
new_from_suffix -
new_slice -
new_slice_from_prefix -
new_slice_from_suffix -
new_zeroed -
new_from_prefix_zeroed -
new_from_suffix_zeroed -
new_slice_zeroed -
new_slice_from_prefix_zeroed -
new_slice_from_suffix_zeroed -
new_unaligned -
new_unaligned_from_prefix -
new_unaligned_from_suffix -
new_slice_unaligned -
new_slice_unaligned_from_prefix -
new_slice_unaligned_from_suffix -
new_unaligned_zeroed -
new_unaligned_from_prefix_zeroed -
new_unaligned_from_suffix_zeroed -
new_slice_unaligned_zeroed -
new_slice_unaligned_from_prefix_zeroed -
new_slice_unaligned_from_suffix_zeroed -
into_ref -
into_mut -
into_slice -
into_mut_slice -
bytes -
bytes_mut -
read -
write -
Debug for LayoutVerified<B, T> -
Debug for LayoutVerified<B, [T]> -
Deref for LayoutVerified<B, T> -
Deref for LayoutVerified<B, [T]> -
DerefMut for LayoutVerified<B, T> -
DerefMut for LayoutVerified<B, [T]> -
Display for LayoutVerified<B, T> -
Display for LayoutVerified<B, [T]> -
Ord for LayoutVerified<B, T> -
Ord for LayoutVerified<B, [T]> -
PartialOrd for LayoutVerified<B, T> -
PartialOrd for LayoutVerified<B, [T]> -
Eq for LayoutVerified<B, T> -
Eq for LayoutVerified<B, [T]> -
PartialEq for LayoutVerified<B, T> -
PartialEq for LayoutVerified<B, [T]>
-
Unalign-
get -
AsBytes for Unalign<T> -
FromBytes for Unalign<T> -
Copy for Unalign<T> -
Clone for Unalign<T>
-
-
extend_vec_zeroed -
insert_vec_zeroed -
transmute!macro