Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove note and checks about NonZero[int] layout. #199

Merged
merged 1 commit into from Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/checked.rs
Expand Up @@ -170,6 +170,7 @@
}
}

// Rust 1.70.0 documents that NonZero[int] has the same layout as [int].
macro_rules! impl_checked_for_nonzero {
($($nonzero:ty: $primitive:ty),* $(,)?) => {
$(
Expand All @@ -178,14 +179,7 @@

#[inline]
fn is_valid_bit_pattern(bits: &Self::Bits) -> bool {
// Note(zachs18): The size and alignment check are almost certainly
// not necessary, but Rust currently doesn't explicitly document that
// NonZero[int] has the same layout as [int], so we check it to be safe.
// In a const to reduce debug-profile overhead.
const LAYOUT_SAME: bool =
core::mem::size_of::<$nonzero>() == core::mem::size_of::<$primitive>()
&& core::mem::align_of::<$nonzero>() == core::mem::align_of::<$primitive>();
LAYOUT_SAME && *bits != 0
*bits != 0
}
}
)*
Expand All @@ -208,7 +202,7 @@

/// The things that can go wrong when casting between [`CheckedBitPattern`] data
/// forms.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

Check failure on line 205 in src/checked.rs

View workflow job for this annotation

GitHub Actions / Test on mips-unknown-linux-gnu with cross

cannot find attribute `derive` in this scope

Check failure on line 205 in src/checked.rs

View workflow job for this annotation

GitHub Actions / Test on mips64-unknown-linux-gnuabi64 with cross

cannot find attribute `derive` in this scope
pub enum CheckedCastError {
/// An error occurred during a true-[`Pod`] cast
///
Expand All @@ -226,7 +220,7 @@
#[cfg(not(target_arch = "spirv"))]
impl core::fmt::Display for CheckedCastError {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "{:?}", self)

Check failure on line 223 in src/checked.rs

View workflow job for this annotation

GitHub Actions / Test on mips-unknown-linux-gnu with cross

cannot find macro `write` in this scope

Check failure on line 223 in src/checked.rs

View workflow job for this annotation

GitHub Actions / Test on mips64-unknown-linux-gnuabi64 with cross

cannot find macro `write` in this scope
}
}
#[cfg(feature = "extern_crate_std")]
Expand Down