Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

zerocopy

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zerocopy - cargo Package Compare versions

Comparing version
0.8.38
to
0.8.39
+1
-1
.cargo_vcs_info.json
{
"git": {
"sha1": "78088c41682d1d07aa471144d67c865d3537c9ad"
"sha1": "e85ea41a646885f291902e707bee68215f88aa3b"
},
"path_in_vcs": ""
}

@@ -274,3 +274,3 @@ # This file is automatically @generated by Cargo.

name = "zerocopy"
version = "0.8.38"
version = "0.8.39"
dependencies = [

@@ -288,5 +288,5 @@ "elain",

name = "zerocopy-derive"
version = "0.8.38"
version = "0.8.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a616990af1a287837c4fe6596ad77ef57948f787e46ce28e166facc0cc1cb75"
checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517"
dependencies = [

@@ -293,0 +293,0 @@ "proc-macro2",

@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

name = "zerocopy"
version = "0.8.38"
version = "0.8.39"
authors = [

@@ -99,3 +99,3 @@ "Joshua Liebow-Feeser <joshlf@google.com>",

[dependencies.zerocopy-derive]
version = "=0.8.38"
version = "=0.8.39"
optional = true

@@ -125,5 +125,5 @@

[dev-dependencies.zerocopy-derive]
version = "=0.8.38"
version = "=0.8.39"
[target."cfg(any())".dependencies.zerocopy-derive]
version = "=0.8.38"
version = "=0.8.39"

@@ -152,1 +152,18 @@ // Copyright 2025 The Fuchsia Authors

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 {}

@@ -42,3 +42,11 @@ // Copyright 2024 The Fuchsia Authors

/// The alignment invariant of a [`Ptr`][super::Ptr].
pub trait Alignment: Sealed {}
pub trait Alignment: Sealed {
#[doc(hidden)]
#[must_use]
fn read<T, I, R>(ptr: crate::Ptr<'_, T, I>) -> T
where
T: Copy + Read<I::Aliasing, R>,
I: Invariants<Alignment = Self, Validity = Valid>,
I::Aliasing: Reference;
}

@@ -136,3 +144,13 @@ /// The validity invariant of a [`Ptr`][super::Ptr].

impl Alignment for Unaligned {}
impl Alignment for Unaligned {
#[inline(always)]
fn read<T, I, R>(ptr: crate::Ptr<'_, T, I>) -> T
where
T: Copy + Read<I::Aliasing, R>,
I: Invariants<Alignment = Self, Validity = Valid>,
I::Aliasing: Reference,
{
(*ptr.into_unalign().as_ref()).into_inner()
}
}

@@ -142,3 +160,13 @@ /// The referent is aligned: for `Ptr<T>`, the referent's address is a multiple

pub enum Aligned {}
impl Alignment for Aligned {}
impl Alignment for Aligned {
#[inline(always)]
fn read<T, I, R>(ptr: crate::Ptr<'_, T, I>) -> T
where
T: Copy + Read<I::Aliasing, R>,
I: Invariants<Alignment = Self, Validity = Valid>,
I::Aliasing: Reference,
{
*ptr.as_ref()
}
}

@@ -145,0 +173,0 @@ /// Any bit pattern is allowed in the `Ptr`'s referent, including uninitialized

@@ -31,4 +31,4 @@ // Copyright 2023 The Fuchsia Authors

/// [`TryFromBytes::is_bit_valid`]: crate::TryFromBytes::is_bit_valid
pub type Maybe<'a, T, Aliasing = invariant::Shared, Alignment = invariant::Unaligned> =
Ptr<'a, ReadOnly<T>, (Aliasing, Alignment, invariant::Initialized)>;
pub type Maybe<'a, T, Alignment = invariant::Unaligned> =
Ptr<'a, ReadOnly<T>, (invariant::Shared, Alignment, invariant::Initialized)>;

@@ -35,0 +35,0 @@ /// Checks if the referent is zeroed.

@@ -138,3 +138,6 @@ // Copyright 2023 The Fuchsia Authors

#[inline]
fn is_bit_valid($candidate: Maybe<'_, Self>) -> bool {
fn is_bit_valid<Alignment>($candidate: Maybe<'_, Self, Alignment>) -> bool
where
Alignment: crate::invariant::Alignment,
{
$is_bit_valid

@@ -147,3 +150,9 @@ }

fn only_derive_is_allowed_to_implement_this_trait() {}
#[inline(always)] fn is_bit_valid(_candidate: Maybe<'_, Self>) -> bool { true }
#[inline(always)]
fn is_bit_valid<Alignment>(_candidate: Maybe<'_, Self, Alignment>) -> bool
where
Alignment: crate::invariant::Alignment,
{
true
}
};

@@ -222,4 +231,7 @@ (@method $trait:ident) => {

) => {
#[inline]
fn is_bit_valid(candidate: $crate::Maybe<'_, Self>) -> bool {
#[inline(always)]
fn is_bit_valid<Alignment>(candidate: $crate::Maybe<'_, Self, Alignment>) -> bool
where
Alignment: $crate::invariant::Alignment,
{
// SAFETY: This macro ensures that `$repr` and `Self` have the same

@@ -316,2 +328,5 @@ // size and bit validity. Thus, a bit-valid instance of `$repr` is

// 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

@@ -337,4 +352,3 @@ /// referencing an existing (derived) implementation.

/// 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

@@ -368,2 +382,3 @@ /// compiled when the `derive` feature is disabled. If that were to happen,

/// ```
#[cfg_attr(__ZEROCOPY_INTERNAL_USE_ONLY_DEV_MODE, macro_export)] // Used in `doctests.rs`
macro_rules! impl_or_verify {

@@ -370,0 +385,0 @@ // The following two match arms follow the same pattern as their

@@ -28,6 +28,7 @@ // Copyright 2019 The Fuchsia Authors

fn ui() {
let version = ToolchainVersion::extract_from_pwd().unwrap();
// See the doc comment on this method for an explanation of what this does
// and why we store source files in different directories.
let source_files_dirname = version.get_ui_source_files_dirname_and_maybe_print_warning();
let source_files_dirname = ToolchainVersion::extract_from_env()
.expect("UI tests must only be run on pinned MSRV, stable, or nightly toolchains")
.get_ui_source_files_dirname();

@@ -41,17 +42,1 @@ // Set `-Wwarnings` in the `RUSTFLAGS` environment variable to ensure that

}
#[test]
#[cfg_attr(miri, ignore)]
fn ui_invalid_impls() {
let version = ToolchainVersion::extract_from_pwd().unwrap();
// See the doc comment on this method for an explanation of what this does
// and why we store source files in different directories.
let source_files_dirname = version.get_ui_source_files_dirname_and_maybe_print_warning();
// Set `-Wwarnings` in the `RUSTFLAGS` environment variable to ensure that
// `.stderr` files reflect what the typical user would encounter.
set_rustflags_w_warnings();
let t = trybuild::TestCases::new();
t.compile_fail(format!("tests/{}/invalid-impls/*.rs", source_files_dirname));
}
// Copyright 2022 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
// Since some macros from `macros.rs` are unused.
#![allow(unused)]
extern crate zerocopy_derive;
include!("../../../src/util/macros.rs");
use zerocopy::*;
use zerocopy_derive::*;
fn main() {}
#[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>);
};

Sorry, the diff of this file is not supported yet

// Copyright 2022 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
// Since some macros from `macros.rs` are unused.
#![allow(unused)]
extern crate zerocopy_derive;
include!("../../../src/util/macros.rs");
use zerocopy::*;
use zerocopy_derive::*;
fn main() {}
#[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>);
};

Sorry, the diff of this file is not supported yet

// Copyright 2022 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
// Since some macros from `macros.rs` are unused.
#![allow(unused)]
extern crate zerocopy_derive;
include!("../../../src/util/macros.rs");
use zerocopy::*;
use zerocopy_derive::*;
fn main() {}
#[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>);
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display