Skip to content

Commit a3e6020

Browse files
committed
rename FromZeroes to FromZeros
`FromZeroes` is retained as a deprecated, `doc(hidden)` re-export.
1 parent cc7a0eb commit a3e6020

33 files changed

+417
-412
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ so you don't have to.
2020
## Overview
2121

2222
Zerocopy provides four core marker traits, each of which can be derived
23-
(e.g., `#[derive(FromZeroes)]`):
24-
- `FromZeroes` indicates that a sequence of zero bytes represents a valid
23+
(e.g., `#[derive(FromZeros)]`):
24+
- `FromZeros` indicates that a sequence of zero bytes represents a valid
2525
instance of a type
2626
- `FromBytes` indicates that a type may safely be converted from an
2727
arbitrary byte sequence
@@ -72,7 +72,7 @@ for network parsing.
7272
```
7373

7474
- **`simd`**
75-
When the `simd` feature is enabled, `FromZeroes`, `FromBytes`, and
75+
When the `simd` feature is enabled, `FromZeros`, `FromBytes`, and
7676
`AsBytes` impls are emitted for all stable SIMD types which exist on the
7777
target platform. Note that the layout of SIMD types is not yet stabilized,
7878
so these impls may be removed in the future if layout changes make them

src/byteorder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
//!
3232
//! ```rust,edition2021
3333
//! # #[cfg(feature = "derive")] { // This example uses derives, and won't compile without them
34-
//! use zerocopy::{AsBytes, ByteSlice, FromBytes, FromZeroes, Ref, Unaligned};
34+
//! use zerocopy::{AsBytes, ByteSlice, FromBytes, FromZeros, Ref, Unaligned};
3535
//! use zerocopy::byteorder::network_endian::U16;
3636
//!
37-
//! #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
37+
//! #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
3838
//! #[repr(C)]
3939
//! struct UdpHeader {
4040
//! src_port: U16,
@@ -176,7 +176,7 @@ example of how it can be used for parsing UDP packets.
176176
[`AsBytes`]: crate::AsBytes
177177
[`Unaligned`]: crate::Unaligned"),
178178
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
179-
#[cfg_attr(any(feature = "derive", test), derive(FromZeroes, FromBytes, AsBytes, Unaligned))]
179+
#[cfg_attr(any(feature = "derive", test), derive(FromZeros, FromBytes, AsBytes, Unaligned))]
180180
#[repr(transparent)]
181181
pub struct $name<O>([u8; $bytes], PhantomData<O>);
182182
}
@@ -185,8 +185,8 @@ example of how it can be used for parsing UDP packets.
185185
/// SAFETY:
186186
/// `$name<O>` is `repr(transparent)`, and so it has the same layout
187187
/// as its only non-zero field, which is a `u8` array. `u8` arrays
188-
/// are `FromZeroes`, `FromBytes`, `AsBytes`, and `Unaligned`.
189-
impl_or_verify!(O => FromZeroes for $name<O>);
188+
/// are `FromZeros`, `FromBytes`, `AsBytes`, and `Unaligned`.
189+
impl_or_verify!(O => FromZeros for $name<O>);
190190
impl_or_verify!(O => FromBytes for $name<O>);
191191
impl_or_verify!(O => AsBytes for $name<O>);
192192
impl_or_verify!(O => Unaligned for $name<O>);

src/lib.rs

Lines changed: 180 additions & 175 deletions
Large diffs are not rendered by default.

src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ macro_rules! unsafe_impl {
130130
///
131131
/// ```rust,ignore
132132
/// // Note that these derives are gated by `feature = "derive"`
133-
/// #[cfg_attr(any(feature = "derive", test), derive(FromZeroes, FromBytes, AsBytes, Unaligned))]
133+
/// #[cfg_attr(any(feature = "derive", test), derive(FromZeros, FromBytes, AsBytes, Unaligned))]
134134
/// #[repr(transparent)]
135135
/// struct Wrapper<T>(T);
136136
///
137137
/// safety_comment! {
138138
/// /// SAFETY:
139139
/// /// `Wrapper<T>` is `repr(transparent)`, so it is sound to implement any
140140
/// /// zerocopy trait if `T` implements that trait.
141-
/// impl_or_verify!(T: FromZeroes => FromZeroes for Wrapper<T>);
141+
/// impl_or_verify!(T: FromZeros => FromZeros for Wrapper<T>);
142142
/// impl_or_verify!(T: FromBytes => FromBytes for Wrapper<T>);
143143
/// impl_or_verify!(T: AsBytes => AsBytes for Wrapper<T>);
144144
/// impl_or_verify!(T: Unaligned => Unaligned for Wrapper<T>);

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub(crate) mod testutil {
107107
// Though `u64` has alignment 8 on some platforms, it's not guaranteed.
108108
// By contrast, `AU64` is guaranteed to have alignment 8.
109109
#[derive(
110-
FromZeroes, FromBytes, AsBytes, Eq, PartialEq, Ord, PartialOrd, Default, Debug, Copy, Clone,
110+
FromZeros, FromBytes, AsBytes, Eq, PartialEq, Ord, PartialOrd, Default, Debug, Copy, Clone,
111111
)]
112112
#[repr(C, align(8))]
113113
pub(crate) struct AU64(pub(crate) u64);

src/wrappers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use super::*;
5454
// [3] https://github.com/google/zerocopy/issues/209
5555
#[allow(missing_debug_implementations)]
5656
#[derive(Default, Copy)]
57-
#[cfg_attr(any(feature = "derive", test), derive(FromZeroes, FromBytes, AsBytes, Unaligned))]
57+
#[cfg_attr(any(feature = "derive", test), derive(FromZeros, FromBytes, AsBytes, Unaligned))]
5858
#[repr(C, packed)]
5959
pub struct Unalign<T>(T);
6060

@@ -63,9 +63,9 @@ safety_comment! {
6363
/// - `Unalign<T>` is `repr(packed)`, so it is unaligned regardless of the
6464
/// alignment of `T`, and so we don't require that `T: Unaligned`
6565
/// - `Unalign<T>` has the same bit validity as `T`, and so it is
66-
/// `FromZeroes`, `FromBytes`, or `AsBytes` exactly when `T` is as well.
66+
/// `FromZeros`, `FromBytes`, or `AsBytes` exactly when `T` is as well.
6767
impl_or_verify!(T => Unaligned for Unalign<T>);
68-
impl_or_verify!(T: FromZeroes => FromZeroes for Unalign<T>);
68+
impl_or_verify!(T: FromZeros => FromZeros for Unalign<T>);
6969
impl_or_verify!(T: FromBytes => FromBytes for Unalign<T>);
7070
impl_or_verify!(T: AsBytes => AsBytes for Unalign<T>);
7171
}

tests/ui-msrv/invalid-impls/invalid-impls.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error[E0277]: the trait bound `T: zerocopy::FromZeroes` is not satisfied
1+
error[E0277]: the trait bound `T: zerocopy::FromZeros` is not satisfied
22
--> tests/ui-msrv/invalid-impls/../../../src/macros.rs
33
|
44
| impl<$($tyvar $(: $(? $optbound +)* $($bound +)*)?),*> Subtrait for $ty {}
5-
| ^^^^^^^^ the trait `zerocopy::FromZeroes` is not implemented for `T`
5+
| ^^^^^^^^ the trait `zerocopy::FromZeros` is not implemented for `T`
66
|
77
::: tests/ui-msrv/invalid-impls/invalid-impls.rs:22:1
88
|
9-
22 | impl_or_verify!(T => FromZeroes for Foo<T>);
9+
22 | impl_or_verify!(T => FromZeros for Foo<T>);
1010
| ------------------------------------------- in this macro invocation
1111
|
12-
note: required because of the requirements on the impl of `zerocopy::FromZeroes` for `Foo<T>`
12+
note: required because of the requirements on the impl of `zerocopy::FromZeros` for `Foo<T>`
1313
--> tests/ui-msrv/invalid-impls/invalid-impls.rs:18:10
1414
|
15-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
15+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
1616
| ^^^^^^^^^^
1717
note: required by a bound in `_::Subtrait`
1818
--> tests/ui-msrv/invalid-impls/../../../src/macros.rs
@@ -22,12 +22,12 @@ note: required by a bound in `_::Subtrait`
2222
|
2323
::: tests/ui-msrv/invalid-impls/invalid-impls.rs:22:1
2424
|
25-
22 | impl_or_verify!(T => FromZeroes for Foo<T>);
25+
22 | impl_or_verify!(T => FromZeros for Foo<T>);
2626
| ------------------------------------------- in this macro invocation
2727
= note: this error originates in the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info)
2828
help: consider restricting type parameter `T`
2929
|
30-
22 | impl_or_verify!(T: zerocopy::FromZeroes => FromZeroes for Foo<T>);
30+
22 | impl_or_verify!(T: zerocopy::FromZeros => FromZeros for Foo<T>);
3131
| ++++++++++++++++++++++
3232

3333
error[E0277]: the trait bound `T: zerocopy::FromBytes` is not satisfied
@@ -44,7 +44,7 @@ error[E0277]: the trait bound `T: zerocopy::FromBytes` is not satisfied
4444
note: required because of the requirements on the impl of `zerocopy::FromBytes` for `Foo<T>`
4545
--> tests/ui-msrv/invalid-impls/invalid-impls.rs:18:22
4646
|
47-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
47+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
4848
| ^^^^^^^^^
4949
note: required by a bound in `_::Subtrait`
5050
--> tests/ui-msrv/invalid-impls/../../../src/macros.rs
@@ -76,7 +76,7 @@ error[E0277]: the trait bound `T: zerocopy::AsBytes` is not satisfied
7676
note: required because of the requirements on the impl of `zerocopy::AsBytes` for `Foo<T>`
7777
--> tests/ui-msrv/invalid-impls/invalid-impls.rs:18:33
7878
|
79-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
79+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
8080
| ^^^^^^^
8181
note: required by a bound in `_::Subtrait`
8282
--> tests/ui-msrv/invalid-impls/../../../src/macros.rs
@@ -108,7 +108,7 @@ error[E0277]: the trait bound `T: zerocopy::Unaligned` is not satisfied
108108
note: required because of the requirements on the impl of `zerocopy::Unaligned` for `Foo<T>`
109109
--> tests/ui-msrv/invalid-impls/invalid-impls.rs:18:42
110110
|
111-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
111+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
112112
| ^^^^^^^^^
113113
note: required by a bound in `_::Subtrait`
114114
--> tests/ui-msrv/invalid-impls/../../../src/macros.rs

tests/ui-nightly/invalid-impls/invalid-impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ use zerocopy_derive::*;
1515

1616
fn main() {}
1717

18-
#[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
18+
#[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
1919
#[repr(transparent)]
2020
struct Foo<T>(T);
2121

22-
impl_or_verify!(T => FromZeroes for Foo<T>);
22+
impl_or_verify!(T => FromZeros for Foo<T>);
2323
impl_or_verify!(T => FromBytes for Foo<T>);
2424
impl_or_verify!(T => AsBytes for Foo<T>);
2525
impl_or_verify!(T => Unaligned for Foo<T>);

tests/ui-nightly/invalid-impls/invalid-impls.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
error[E0277]: the trait bound `T: zerocopy::FromZeroes` is not satisfied
1+
error[E0277]: the trait bound `T: zerocopy::FromZeros` is not satisfied
22
--> tests/ui-nightly/invalid-impls/invalid-impls.rs:22:37
33
|
4-
22 | impl_or_verify!(T => FromZeroes for Foo<T>);
5-
| ^^^^^^ the trait `zerocopy::FromZeroes` is not implemented for `T`
4+
22 | impl_or_verify!(T => FromZeros for Foo<T>);
5+
| ^^^^^^ the trait `zerocopy::FromZeros` is not implemented for `T`
66
|
7-
note: required for `Foo<T>` to implement `zerocopy::FromZeroes`
7+
note: required for `Foo<T>` to implement `zerocopy::FromZeros`
88
--> tests/ui-nightly/invalid-impls/invalid-impls.rs:18:10
99
|
10-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
10+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
1111
| ^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
1212
note: required by a bound in `_::Subtrait`
1313
--> tests/ui-nightly/invalid-impls/../../../src/macros.rs
@@ -17,12 +17,12 @@ note: required by a bound in `_::Subtrait`
1717
|
1818
::: tests/ui-nightly/invalid-impls/invalid-impls.rs:22:1
1919
|
20-
22 | impl_or_verify!(T => FromZeroes for Foo<T>);
20+
22 | impl_or_verify!(T => FromZeros for Foo<T>);
2121
| ------------------------------------------- in this macro invocation
22-
= note: this error originates in the derive macro `FromZeroes` which comes from the expansion of the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
= note: this error originates in the derive macro `FromZeros` which comes from the expansion of the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info)
2323
help: consider restricting type parameter `T`
2424
|
25-
22 | impl_or_verify!(T: zerocopy::FromZeroes => FromZeroes for Foo<T>);
25+
22 | impl_or_verify!(T: zerocopy::FromZeros => FromZeros for Foo<T>);
2626
| ++++++++++++++++++++++
2727

2828
error[E0277]: the trait bound `T: zerocopy::FromBytes` is not satisfied
@@ -34,7 +34,7 @@ error[E0277]: the trait bound `T: zerocopy::FromBytes` is not satisfied
3434
note: required for `Foo<T>` to implement `zerocopy::FromBytes`
3535
--> tests/ui-nightly/invalid-impls/invalid-impls.rs:18:22
3636
|
37-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
37+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
3838
| ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
3939
note: required by a bound in `_::Subtrait`
4040
--> tests/ui-nightly/invalid-impls/../../../src/macros.rs
@@ -61,7 +61,7 @@ error[E0277]: the trait bound `T: zerocopy::AsBytes` is not satisfied
6161
note: required for `Foo<T>` to implement `zerocopy::AsBytes`
6262
--> tests/ui-nightly/invalid-impls/invalid-impls.rs:18:33
6363
|
64-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
64+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
6565
| ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
6666
note: required by a bound in `_::Subtrait`
6767
--> tests/ui-nightly/invalid-impls/../../../src/macros.rs
@@ -88,7 +88,7 @@ error[E0277]: the trait bound `T: zerocopy::Unaligned` is not satisfied
8888
note: required for `Foo<T>` to implement `zerocopy::Unaligned`
8989
--> tests/ui-nightly/invalid-impls/invalid-impls.rs:18:42
9090
|
91-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
91+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
9292
| ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
9393
note: required by a bound in `_::Subtrait`
9494
--> tests/ui-nightly/invalid-impls/../../../src/macros.rs

tests/ui-stable/invalid-impls/invalid-impls.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
error[E0277]: the trait bound `T: zerocopy::FromZeroes` is not satisfied
1+
error[E0277]: the trait bound `T: zerocopy::FromZeros` is not satisfied
22
--> tests/ui-stable/invalid-impls/invalid-impls.rs:22:37
33
|
4-
22 | impl_or_verify!(T => FromZeroes for Foo<T>);
5-
| ^^^^^^ the trait `zerocopy::FromZeroes` is not implemented for `T`
4+
22 | impl_or_verify!(T => FromZeros for Foo<T>);
5+
| ^^^^^^ the trait `zerocopy::FromZeros` is not implemented for `T`
66
|
7-
note: required for `Foo<T>` to implement `zerocopy::FromZeroes`
7+
note: required for `Foo<T>` to implement `zerocopy::FromZeros`
88
--> tests/ui-stable/invalid-impls/invalid-impls.rs:18:10
99
|
10-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
10+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
1111
| ^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
1212
note: required by a bound in `_::Subtrait`
1313
--> tests/ui-stable/invalid-impls/../../../src/macros.rs
@@ -17,12 +17,12 @@ note: required by a bound in `_::Subtrait`
1717
|
1818
::: tests/ui-stable/invalid-impls/invalid-impls.rs:22:1
1919
|
20-
22 | impl_or_verify!(T => FromZeroes for Foo<T>);
20+
22 | impl_or_verify!(T => FromZeros for Foo<T>);
2121
| ------------------------------------------- in this macro invocation
22-
= note: this error originates in the derive macro `FromZeroes` which comes from the expansion of the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
= note: this error originates in the derive macro `FromZeros` which comes from the expansion of the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info)
2323
help: consider restricting type parameter `T`
2424
|
25-
22 | impl_or_verify!(T: zerocopy::FromZeroes => FromZeroes for Foo<T>);
25+
22 | impl_or_verify!(T: zerocopy::FromZeros => FromZeros for Foo<T>);
2626
| ++++++++++++++++++++++
2727

2828
error[E0277]: the trait bound `T: zerocopy::FromBytes` is not satisfied
@@ -34,7 +34,7 @@ error[E0277]: the trait bound `T: zerocopy::FromBytes` is not satisfied
3434
note: required for `Foo<T>` to implement `zerocopy::FromBytes`
3535
--> tests/ui-stable/invalid-impls/invalid-impls.rs:18:22
3636
|
37-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
37+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
3838
| ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
3939
note: required by a bound in `_::Subtrait`
4040
--> tests/ui-stable/invalid-impls/../../../src/macros.rs
@@ -61,7 +61,7 @@ error[E0277]: the trait bound `T: zerocopy::AsBytes` is not satisfied
6161
note: required for `Foo<T>` to implement `zerocopy::AsBytes`
6262
--> tests/ui-stable/invalid-impls/invalid-impls.rs:18:33
6363
|
64-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
64+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
6565
| ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
6666
note: required by a bound in `_::Subtrait`
6767
--> tests/ui-stable/invalid-impls/../../../src/macros.rs
@@ -88,7 +88,7 @@ error[E0277]: the trait bound `T: zerocopy::Unaligned` is not satisfied
8888
note: required for `Foo<T>` to implement `zerocopy::Unaligned`
8989
--> tests/ui-stable/invalid-impls/invalid-impls.rs:18:42
9090
|
91-
18 | #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
91+
18 | #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
9292
| ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
9393
note: required by a bound in `_::Subtrait`
9494
--> tests/ui-stable/invalid-impls/../../../src/macros.rs

0 commit comments

Comments
 (0)