Skip to content

Commit a538d86

Browse files
authored
Merge branch 'main' into byteorder-no-crate-dep
2 parents 3011972 + e56a42b commit a538d86

File tree

171 files changed

+4463
-2120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+4463
-2120
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Customer request
3+
about: Describe what features you'd like from zerocopy for your project
4+
title: Features to support <project>
5+
labels: customer-request
6+
assignees: ''
7+
8+
---
9+
10+
**What is the name of your project?**
11+
12+
**Please provide a link to your project (GitHub repository, crates.io page, etc).**
13+
14+
**What features would you like from zerocopy?**
15+
For each feature:
16+
- Describe why it would be useful to your project, providing any useful context (GitHub links, etc).
17+
- If there is an existing zerocopy GitHub issue describing this feature, link to it.

.github/workflows/ci.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,7 @@ jobs:
251251
# an API that cargo-semver-checks can understand.
252252
package: zerocopy
253253
feature-group: all-features
254-
# TODO: Set this to the specific nightly we have pinned in CI. Not a big
255-
# deal since this isn't affected by the trybuild stderr files, which is
256-
# the reason we need to pin to a specific nightly.
257-
rust-toolchain: nightly
254+
rust-toolchain: ${{ env.ZC_TOOLCHAIN }}
258255
if: matrix.crate == 'zerocopy' && matrix.features == '--all-features' && matrix.toolchain == 'nightly'
259256

260257
kani:
@@ -461,6 +458,40 @@ jobs:
461458
cargo install --locked kani-verifier &> /dev/null || true
462459
cargo kani setup &> /dev/null || true
463460
461+
check-job-dependencies:
462+
runs-on: ubuntu-latest
463+
name: Check all-jobs-succeeded depends on all jobs
464+
steps:
465+
- name: Install yq (for YAML parsing)
466+
run: go install github.com/mikefarah/yq/v4@latest
467+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
468+
- name: Run dependency check
469+
run: |
470+
set -eo pipefail
471+
jobs=$(for i in $(find .github -iname '*.yaml' -or -iname '*.yml')
472+
do
473+
# Select jobs that are triggered by pull request.
474+
if yq -e '.on | has("pull_request")' "$i" 2>/dev/null >/dev/null
475+
then
476+
# This gets the list of jobs that all-jobs-succeed does not depend on.
477+
comm -23 \
478+
<(yq -r '.jobs | keys | .[]' "$i" | sort | uniq) \
479+
<(yq -r '.jobs.all-jobs-succeed.needs[]' "$i" | sort | uniq)
480+
fi
481+
482+
# The grep call here excludes all-jobs-succeed from the list of jobs that
483+
# all-jobs-succeed does not depend on. If all-jobs-succeed does
484+
# not depend on itself, we do not care about it.
485+
done | sort | uniq | (grep -v '^all-jobs-succeed$' || true)
486+
)
487+
488+
if [ -n "$jobs" ]
489+
then
490+
missing_jobs="$(echo "$jobs" | tr ' ' '\n')"
491+
echo "all-jobs-succeed missing dependencies on some jobs: $missing_jobs" | tee -a $GITHUB_STEP_SUMMARY
492+
exit 1
493+
fi
494+
464495
# Used to signal to branch protections that all other jobs have succeeded.
465496
all-jobs-succeed:
466497
name: All checks succeeded
@@ -471,7 +502,7 @@ jobs:
471502
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
472503
if: failure()
473504
runs-on: ubuntu-latest
474-
needs: [build_test, kani, check_fmt, check_readme, check_msrv, check_versions, generate_cache]
505+
needs: [build_test, kani, check_fmt, check_readme, check_msrv, check_versions, generate_cache, check-job-dependencies]
475506
steps:
476507
- name: Mark the job as failed
477508
run: exit 1

.github/workflows/scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ jobs:
5050
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
5151
# format to the repository Actions tab.
5252
- name: "Upload artifact"
53-
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
53+
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
5454
with:
5555
name: SARIF file
5656
path: results.sarif
5757
retention-days: 5
5858

5959
# Upload the results to GitHub's code scanning dashboard.
6060
- name: "Upload to code-scanning"
61-
uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
61+
uses: github/codeql-action/upload-sarif@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12
6262
with:
6363
sarif_file: results.sarif

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog
2+
3+
## Releases
4+
5+
We track releases and release notes using [GitHub
6+
Releases](https://github.com/google/zerocopy/releases).
7+
8+
## Yanks and Regressions
9+
10+
### 0.2.2 through 0.2.8, 0.3.0 through 0.3.1, 0.4.0, 0.5.0, 0.6.0 through 0.6.5, 0.7.0 through 0.7.30
11+
12+
*Security advisories for this bug have been published as
13+
[RUSTSEC-2023-0074][rustsec-advisory] and [GHSA-3mv5-343c-w2qg][github-advisory].*
14+
15+
In these versions, the `Ref` methods `into_ref`, `into_mut`, `into_slice`, and
16+
`into_mut_slice` were permitted in combination with the standard library
17+
`cell::Ref` and `cell::RefMut` types for `Ref<B, T>`'s `B` type parameter. These
18+
combinations are unsound, and may permit safe code to exhibit undefined
19+
behavior. Fixes have been published to each affected minor version which do not
20+
permit this code to compile.
21+
22+
See [#716][issue-716] for more details.
23+
24+
[rustsec-advisory]: https://rustsec.org/advisories/RUSTSEC-2023-0074.html
25+
[github-advisory]: https://github.com/google/zerocopy/security/advisories/GHSA-3mv5-343c-w2qg
26+
[issue-716]: https://github.com/google/zerocopy/issues/716
27+
28+
### 0.7.27, 0.7.28
29+
30+
These versions were briefly yanked due to a non-soundness regression reported in
31+
[#672][pull-672]. After reconsidering our yanking policy in [#679][issue-679],
32+
we un-yanked these versions.
33+
34+
[pull-672]: https://github.com/google/zerocopy/pull/672
35+
[issue-679]: https://github.com/google/zerocopy/issues/679

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ name of that subsystem in square brackets, omitting any "zerocopy" prefix
157157
zerocopy-derive crate:
158158

159159
```text
160-
[derive] Support AsBytes on types with parameters
160+
[derive] Support IntoBytes on types with parameters
161161
```
162162

163163
The body may be omitted if the subject is self-explanatory; e.g. when fixing a

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[package]
1616
edition = "2018"
1717
name = "zerocopy"
18-
version = "0.8.0-alpha"
18+
version = "0.8.0-alpha.1"
1919
authors = ["Joshua Liebow-Feeser <[email protected]>"]
2020
description = "Utilities for zero-copy parsing and serialization"
2121
license = "BSD-2-Clause OR Apache-2.0 OR MIT"
@@ -30,8 +30,8 @@ rustdoc-args = ["--cfg", "doc_cfg", "--generate-link-to-definition"]
3030

3131
[package.metadata.ci]
3232
# The versions of the stable and nightly compiler toolchains to use in CI.
33-
pinned-stable = "1.74.0"
34-
pinned-nightly = "nightly-2023-12-05"
33+
pinned-stable = "1.74.1"
34+
pinned-nightly = "nightly-2023-12-22"
3535

3636
[package.metadata.playground]
3737
features = ["__internal_use_only_features_that_work_on_stable"]
@@ -47,13 +47,13 @@ simd-nightly = ["simd"]
4747
__internal_use_only_features_that_work_on_stable = ["alloc", "derive", "simd"]
4848

4949
[dependencies]
50-
zerocopy-derive = { version = "=0.8.0-alpha", path = "zerocopy-derive", optional = true }
50+
zerocopy-derive = { version = "=0.8.0-alpha.1", path = "zerocopy-derive", optional = true }
5151

5252
# The "associated proc macro pattern" ensures that the versions of zerocopy and
5353
# zerocopy-derive remain equal, even if the 'derive' feature isn't used.
5454
# See: https://github.com/matklad/macro-dep-test
5555
[target.'cfg(any())'.dependencies]
56-
zerocopy-derive = { version = "=0.8.0-alpha", path = "zerocopy-derive" }
56+
zerocopy-derive = { version = "=0.8.0-alpha.1", path = "zerocopy-derive" }
5757

5858
[dev-dependencies]
5959
assert_matches = "1.5"
@@ -68,6 +68,6 @@ testutil = { path = "testutil" }
6868
# CI test failures.
6969
trybuild = { version = "=1.0.85", features = ["diff"] }
7070
# In tests, unlike in production, zerocopy-derive is not optional
71-
zerocopy-derive = { version = "=0.8.0-alpha", path = "zerocopy-derive" }
71+
zerocopy-derive = { version = "=0.8.0-alpha.1", path = "zerocopy-derive" }
7272
# TODO(#381) Remove this dependency once we have our own layout gadgets.
7373
elain = "0.3.0"

POLICIES.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,10 @@ increase our MSRV during semver-breaking version changes (e.g., 0.1 -> 0.2, 1.0
9999
Whenever a bug or regression is identified, we will yank any affected versions
100100
which are part of the current version train. For example, if the most recent
101101
version is 0.10.20 and a bug is uncovered, we will release a fix in 0.10.21 and
102-
yank all 0.10.X versions which are affected. We *may* also yank versions in previous
103-
version trains on a case-by-case basis, but we don't guarantee it.
102+
yank all 0.10.X versions which are affected. We *may* also yank versions in
103+
previous version trains on a case-by-case basis, but we don't guarantee it.
104+
105+
For information about a particular yanked or un-yanked version, see our [yank
106+
log][yank-log].
107+
108+
[yank-log]: https://github.com/google/zerocopy/blob/main/CHANGELOG.md#yanks-and-regressions

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ made in the doc comment on `src/lib.rs` or in `generate-readme.sh`.
1212

1313
# zerocopy
1414

15-
*<span style="font-size: 100%; color:grey;">Want to help improve zerocopy?
16-
Fill out our [user survey][user-survey]!</span>*
15+
*<span style="font-size: 100%; color:grey;">Need more out of zerocopy?
16+
Submit a [customer request issue][customer-request-issue]!</span>*
1717

1818
***<span style="font-size: 140%">Fast, safe, <span
1919
style="color:red;">compile error</span>. Pick two.</span>***
@@ -24,12 +24,12 @@ so you don't have to.
2424
## Overview
2525

2626
Zerocopy provides four core marker traits, each of which can be derived
27-
(e.g., `#[derive(FromZeroes)]`):
28-
- `FromZeroes` indicates that a sequence of zero bytes represents a valid
27+
(e.g., `#[derive(FromZeros)]`):
28+
- `FromZeros` indicates that a sequence of zero bytes represents a valid
2929
instance of a type
3030
- `FromBytes` indicates that a type may safely be converted from an
3131
arbitrary byte sequence
32-
- `AsBytes` indicates that a type may safely be converted *to* a byte
32+
- `IntoBytes` indicates that a type may safely be converted *to* a byte
3333
sequence
3434
- `Unaligned` indicates that a type's alignment requirement is 1
3535

@@ -40,7 +40,7 @@ Zerocopy also provides byte-order aware integer types that support these
4040
conversions; see the `byteorder` module. These types are especially useful
4141
for network parsing.
4242

43-
[user-survey]: https://docs.google.com/forms/d/e/1FAIpQLSdzBNTN9tzwsmtyZxRFNL02K36IWCdHWW2ZBckyQS2xiO3i8Q/viewform?usp=published_options
43+
[customer-request-issue]: https://github.com/google/zerocopy/issues/new/choose
4444

4545
## Cargo Features
4646

@@ -67,8 +67,8 @@ for network parsing.
6767
```
6868

6969
- **`simd`**
70-
When the `simd` feature is enabled, `FromZeroes`, `FromBytes`, and
71-
`AsBytes` impls are emitted for all stable SIMD types which exist on the
70+
When the `simd` feature is enabled, `FromZeros`, `FromBytes`, and
71+
`IntoBytes` impls are emitted for all stable SIMD types which exist on the
7272
target platform. Note that the layout of SIMD types is not yet stabilized,
7373
so these impls may be removed in the future if layout changes make them
7474
invalid. For more information, see the Unsafe Code Guidelines Reference
@@ -134,6 +134,12 @@ See our [MSRV policy].
134134

135135
[MSRV policy]: https://github.com/google/zerocopy/blob/main/POLICIES.md#msrv
136136

137+
## Changelog
138+
139+
Zerocopy uses [GitHub Releases].
140+
141+
[GitHub Releases]: https://github.com/google/zerocopy/releases
142+
137143
## Disclaimer
138144

139145
Disclaimer: Zerocopy is not an officially supported Google product.

src/byteorder.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! this module - [`U16`], [`I16`], [`U32`], [`F64`], etc. Unlike their native
1717
//! counterparts, these types have alignment 1, and take a type parameter
1818
//! specifying the byte order in which the bytes are stored in memory. Each type
19-
//! implements the [`FromBytes`], [`AsBytes`], and [`Unaligned`] traits.
19+
//! implements the [`FromBytes`], [`IntoBytes`], and [`Unaligned`] traits.
2020
//!
2121
//! These two properties, taken together, make these types useful for defining
2222
//! data structures whose memory layout matches a wire format such as that of a
@@ -35,10 +35,10 @@
3535
//!
3636
//! ```rust,edition2021
3737
//! # #[cfg(feature = "derive")] { // This example uses derives, and won't compile without them
38-
//! use zerocopy::{AsBytes, ByteSlice, FromBytes, FromZeroes, Ref, Unaligned};
38+
//! use zerocopy::{IntoBytes, ByteSlice, FromBytes, FromZeros, NoCell, Ref, Unaligned};
3939
//! use zerocopy::byteorder::network_endian::U16;
4040
//!
41-
//! #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
41+
//! #[derive(FromZeros, FromBytes, IntoBytes, NoCell, Unaligned)]
4242
//! #[repr(C)]
4343
//! struct UdpHeader {
4444
//! src_port: U16,
@@ -346,18 +346,18 @@ order to uphold the invariants that a) the layout of `", stringify!($name), "`
346346
has endianness `O` and that, b) the layout of `", stringify!($native), "` has
347347
the platform's native endianness.
348348
349-
`", stringify!($name), "` implements [`FromBytes`], [`AsBytes`], and [`Unaligned`],
349+
`", stringify!($name), "` implements [`FromBytes`], [`IntoBytes`], and [`Unaligned`],
350350
making it useful for parsing and serialization. See the module documentation for an
351351
example of how it can be used for parsing UDP packets.
352352
353353
[`new`]: crate::byteorder::", stringify!($name), "::new
354354
[`get`]: crate::byteorder::", stringify!($name), "::get
355355
[`set`]: crate::byteorder::", stringify!($name), "::set
356356
[`FromBytes`]: crate::FromBytes
357-
[`AsBytes`]: crate::AsBytes
357+
[`IntoBytes`]: crate::IntoBytes
358358
[`Unaligned`]: crate::Unaligned"),
359359
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
360-
#[cfg_attr(any(feature = "derive", test), derive(KnownLayout, FromZeroes, FromBytes, AsBytes, Unaligned))]
360+
#[cfg_attr(any(feature = "derive", test), derive(KnownLayout, NoCell, FromZeros, FromBytes, IntoBytes, Unaligned))]
361361
#[repr(transparent)]
362362
pub struct $name<O>([u8; $bytes], PhantomData<O>);
363363
}
@@ -369,10 +369,12 @@ example of how it can be used for parsing UDP packets.
369369
/// SAFETY:
370370
/// `$name<O>` is `repr(transparent)`, and so it has the same layout
371371
/// as its only non-zero field, which is a `u8` array. `u8` arrays
372-
/// are `FromZeroes`, `FromBytes`, `AsBytes`, and `Unaligned`.
373-
impl_or_verify!(O => FromZeroes for $name<O>);
372+
/// are `NoCell`, `FromZeros`, `FromBytes`, `IntoBytes`, and
373+
/// `Unaligned`.
374+
impl_or_verify!(O => NoCell for $name<O>);
375+
impl_or_verify!(O => FromZeros for $name<O>);
374376
impl_or_verify!(O => FromBytes for $name<O>);
375-
impl_or_verify!(O => AsBytes for $name<O>);
377+
impl_or_verify!(O => IntoBytes for $name<O>);
376378
impl_or_verify!(O => Unaligned for $name<O>);
377379
}
378380

@@ -813,7 +815,7 @@ module!(native_endian, NativeEndian, "native-endian");
813815
mod tests {
814816
use {
815817
super::*,
816-
crate::{AsBytes, FromBytes, Unaligned},
818+
crate::{FromBytes, IntoBytes, Unaligned},
817819
};
818820

819821
#[cfg(not(kani))]
@@ -861,7 +863,7 @@ mod tests {
861863
use compatibility::*;
862864

863865
// A native integer type (u16, i32, etc).
864-
trait Native: Arbitrary + FromBytes + AsBytes + Copy + PartialEq + Debug {
866+
trait Native: Arbitrary + FromBytes + IntoBytes + NoCell + Copy + PartialEq + Debug {
865867
const ZERO: Self;
866868
const MAX_VALUE: Self;
867869

@@ -898,13 +900,13 @@ mod tests {
898900
}
899901

900902
trait ByteArray:
901-
FromBytes + AsBytes + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
903+
FromBytes + IntoBytes + NoCell + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
902904
{
903905
/// Invert the order of the bytes in the array.
904906
fn invert(self) -> Self;
905907
}
906908

907-
trait ByteOrderType: FromBytes + AsBytes + Unaligned + Copy + Eq + Debug {
909+
trait ByteOrderType: FromBytes + IntoBytes + Unaligned + Copy + Eq + Debug {
908910
type Native: Native;
909911
type ByteArray: ByteArray;
910912

0 commit comments

Comments
 (0)