Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
49 changes: 1 addition & 48 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
# paths that are stable regardless of the path to the repository root. This
# avoids issues like:
# https://github.com/dtolnay/trybuild/issues/207#issuecomment-131227.594
[workspace]
[[test]]
name = "ui"
path = "tests/ui.rs"
harness = false

[workspace]
members = []
[package]
edition = "2021"
name = "zerocopy"
Expand Down Expand Up @@ -128,10 +133,6 @@ rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }
rustversion = "1.0"
static_assertions = "1.1"
testutil = { path = "testutil" }
# Pinned to a specific version so that the version used for local development
# and the version used in CI are guaranteed to be the same. Future versions
# sometimes change the output format slightly, so a version mismatch can cause
# CI test failures.
trybuild = { version = "=1.0.89", features = ["diff"] }
# In tests, unlike in production, zerocopy-derive is not optional
zerocopy-derive = { version = "=0.8.38", path = "zerocopy-derive" }
zerocopy = { path = ".", features = ["derive"] }
9 changes: 8 additions & 1 deletion ci/check_fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ if [[ -z $files ]]
then
exit 1
fi
./cargo.sh +nightly fmt --check -- $files >&2

if [[ "$1" == "--fix" ]]; then
FMT_FLAGS=""
else
FMT_FLAGS="--check"
fi

./cargo.sh +nightly fmt $FMT_FLAGS -- $files >&2
10 changes: 9 additions & 1 deletion ci/check_stale_stderr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ for dir in "${DIRS[@]}"; do

# Find all .stderr files
while IFS= read -r -d '' stderr_file; do
# Strip .stderr extension
base="${stderr_file%.stderr}"

# Strip toolchain suffixes
base="${base%.msrv}"
base="${base%.stable}"
base="${base%.nightly}"

# Construct the corresponding .rs file path
rs_file="${stderr_file%.stderr}.rs"
rs_file="${base}.rs"

# Check if the .rs file exists. The `-e` flag checks if file exists:
# It returns true for regular files and valid symlinks, and false for
Expand Down
17 changes: 17 additions & 0 deletions src/doctests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,20 @@ enum TransmuteRefMutDstOffsetNotMultiple {}
/// let _: &mut SliceDst<(), [u8; 2]> = zerocopy::transmute_mut!(src);
/// ```
enum TransmuteRefMutDstElemSizeNotMultiple {}

/// ```compile_fail,E0277
/// use zerocopy::*;
///
/// #[derive(FromBytes, IntoBytes, Unaligned)]
/// #[repr(transparent)]
/// struct Foo<T>(T);
///
/// const _: () = unsafe {
/// impl_or_verify!(T => TryFromBytes for Foo<T>);
/// impl_or_verify!(T => FromZeros for Foo<T>);
/// impl_or_verify!(T => FromBytes for Foo<T>);
/// impl_or_verify!(T => IntoBytes for Foo<T>);
/// impl_or_verify!(T => Unaligned for Foo<T>);
/// };
/// ```
enum InvalidImplOrVerify {}
7 changes: 5 additions & 2 deletions src/util/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ macro_rules! opt_unsafe_fn {
($($args:ident),* -> $ret:ident) => { Option<unsafe fn($($args),*) -> $ret> };
}

// This `allow` is needed because, when testing, we export this macro so it can
// be used in `doctests`.
#[allow(rustdoc::private_intra_doc_links)]
/// Implements trait(s) for a type or verifies the given implementation by
/// referencing an existing (derived) implementation.
///
Expand All @@ -342,8 +345,7 @@ macro_rules! opt_unsafe_fn {
/// `const _: () = unsafe` macro). The reason for this restriction is that,
/// while `impl_or_verify!` can guarantee that the provided impl is sound when
/// it is compiled with the appropriate cfgs, there is no way to guarantee that
/// it is
/// ever compiled with those cfgs. In particular, it would be possible to
/// it is ever compiled with those cfgs. In particular, it would be possible to
/// accidentally place an `impl_or_verify!` call in a context that is only ever
/// compiled when the `derive` feature is disabled. If that were to happen,
/// there would be nothing to prevent an unsound trait impl from being emitted.
Expand Down Expand Up @@ -372,6 +374,7 @@ macro_rules! opt_unsafe_fn {
/// impl_or_verify!(T: Unaligned => Unaligned for Wrapper<T>);
/// }
/// ```
#[cfg_attr(__ZEROCOPY_INTERNAL_USE_ONLY_DEV_MODE, macro_export)] // Used in `doctests.rs`
macro_rules! impl_or_verify {
// The following two match arms follow the same pattern as their
// counterparts in `unsafe_impl!`; see the documentation on those arms for
Expand Down
55 changes: 0 additions & 55 deletions tests/trybuild.rs

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui-msrv/diagnostic-not-implemented-from-bytes.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui-msrv/diagnostic-not-implemented-from-bytes.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui-msrv/diagnostic-not-implemented-from-zeros.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui-msrv/diagnostic-not-implemented-from-zeros.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui-msrv/diagnostic-not-implemented-immutable.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui-msrv/diagnostic-not-implemented-immutable.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui-msrv/diagnostic-not-implemented-into-bytes.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui-msrv/diagnostic-not-implemented-into-bytes.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui-msrv/diagnostic-not-implemented-issue-1296.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui-msrv/diagnostic-not-implemented-issue-1296.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui-msrv/diagnostic-not-implemented-known-layout.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui-msrv/diagnostic-not-implemented-known-layout.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui-msrv/diagnostic-not-implemented-try-from-bytes.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui-msrv/diagnostic-not-implemented-try-from-bytes.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui-msrv/diagnostic-not-implemented-unaligned.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui-msrv/diagnostic-not-implemented-unaligned.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui-msrv/include_value_not_from_bytes.rs

This file was deleted.

15 changes: 0 additions & 15 deletions tests/ui-msrv/include_value_not_from_bytes.stderr

This file was deleted.

Loading
Loading