Skip to content

Commit

Permalink
Use feature(doc_auto_cfg) instead of feature(doc_cfg) with manual…
Browse files Browse the repository at this point in the history
… annotations under `nightly_docs` cargo feature.
  • Loading branch information
zachs18 committed Dec 7, 2024
1 parent 227d7fe commit 67d0a73
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 47 deletions.
4 changes: 0 additions & 4 deletions src/anybitpattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,5 @@ pub unsafe trait AnyBitPattern:
unsafe impl<T: Pod> AnyBitPattern for T {}

#[cfg(feature = "zeroable_maybe_uninit")]
#[cfg_attr(
feature = "nightly_docs",
doc(cfg(feature = "zeroable_maybe_uninit"))
)]
unsafe impl<T> AnyBitPattern for core::mem::MaybeUninit<T> where T: AnyBitPattern
{}
1 change: 0 additions & 1 deletion src/checked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ impl core::fmt::Display for CheckedCastError {
}
}
#[cfg(feature = "extern_crate_std")]
#[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "extern_crate_std")))]
impl std::error::Error for CheckedCastError {}

impl From<crate::PodCastError> for CheckedCastError {
Expand Down
7 changes: 1 addition & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![allow(clippy::uninlined_format_args)]
#![allow(clippy::result_unit_err)]
#![allow(clippy::type_complexity)]
#![cfg_attr(feature = "nightly_docs", feature(doc_cfg))]
#![cfg_attr(feature = "nightly_docs", feature(doc_auto_cfg))]
#![cfg_attr(feature = "nightly_portable_simd", feature(portable_simd))]
#![cfg_attr(feature = "nightly_float", feature(f16, f128))]
#![cfg_attr(
Expand Down Expand Up @@ -147,7 +147,6 @@ macro_rules! impl_unsafe_marker_for_simd {
($(#[cfg($cfg_predicate:meta)])? unsafe impl $trait:ident for $platform:ident :: {}) => {};
($(#[cfg($cfg_predicate:meta)])? unsafe impl $trait:ident for $platform:ident :: { $first_type:ident $(, $types:ident)* $(,)? }) => {
$( #[cfg($cfg_predicate)] )?
$( #[cfg_attr(feature = "nightly_docs", doc(cfg($cfg_predicate)))] )?
unsafe impl $trait for $platform::$first_type {}
$( #[cfg($cfg_predicate)] )? // To prevent recursion errors if nothing is going to be expanded anyway.
impl_unsafe_marker_for_simd!($( #[cfg($cfg_predicate)] )? unsafe impl $trait for $platform::{ $( $types ),* });
Expand All @@ -160,7 +159,6 @@ extern crate std;
#[cfg(feature = "extern_crate_alloc")]
extern crate alloc;
#[cfg(feature = "extern_crate_alloc")]
#[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "extern_crate_alloc")))]
pub mod allocation;
#[cfg(feature = "extern_crate_alloc")]
pub use allocation::*;
Expand All @@ -186,7 +184,6 @@ pub use pod_in_option::*;
#[cfg(feature = "must_cast")]
mod must;
#[cfg(feature = "must_cast")]
#[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "must_cast")))]
pub use must::*;

mod no_uninit;
Expand All @@ -203,7 +200,6 @@ mod transparent;
pub use transparent::*;

#[cfg(feature = "derive")]
#[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "derive")))]
pub use bytemuck_derive::{
AnyBitPattern, ByteEq, ByteHash, CheckedBitPattern, Contiguous, NoUninit,
Pod, TransparentWrapper, Zeroable,
Expand Down Expand Up @@ -237,7 +233,6 @@ impl core::fmt::Display for PodCastError {
}
}
#[cfg(feature = "extern_crate_std")]
#[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "extern_crate_std")))]
impl std::error::Error for PodCastError {}

/// Re-interprets `&T` as `&[u8]`.
Expand Down
17 changes: 0 additions & 17 deletions src/pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,10 @@ unsafe impl Pod for f128 {}
unsafe impl<T: Pod> Pod for Wrapping<T> {}

#[cfg(feature = "unsound_ptr_pod_impl")]
#[cfg_attr(
feature = "nightly_docs",
doc(cfg(feature = "unsound_ptr_pod_impl"))
)]
unsafe impl<T: 'static> Pod for *mut T {}
#[cfg(feature = "unsound_ptr_pod_impl")]
#[cfg_attr(
feature = "nightly_docs",
doc(cfg(feature = "unsound_ptr_pod_impl"))
)]
unsafe impl<T: 'static> Pod for *const T {}
#[cfg(feature = "unsound_ptr_pod_impl")]
#[cfg_attr(
feature = "nightly_docs",
doc(cfg(feature = "unsound_ptr_pod_impl"))
)]
unsafe impl<T: 'static> PodInOption for NonNull<T> {}

unsafe impl<T: ?Sized + 'static> Pod for PhantomData<T> {}
Expand All @@ -83,7 +71,6 @@ unsafe impl<T: Pod> Pod for core::mem::ManuallyDrop<T> {}
// Note(Lokathor): MaybeUninit can NEVER be Pod.

#[cfg(feature = "min_const_generics")]
#[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "min_const_generics")))]
unsafe impl<T, const N: usize> Pod for [T; N] where T: Pod {}

#[cfg(not(feature = "min_const_generics"))]
Expand Down Expand Up @@ -141,10 +128,6 @@ impl_unsafe_marker_for_simd!(
);

#[cfg(feature = "nightly_portable_simd")]
#[cfg_attr(
feature = "nightly_docs",
doc(cfg(feature = "nightly_portable_simd"))
)]
unsafe impl<T, const N: usize> Pod for core::simd::Simd<T, N>
where
T: core::simd::SimdElement + Pod,
Expand Down
8 changes: 0 additions & 8 deletions src/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,11 @@ pub unsafe trait TransparentWrapper<Inner: ?Sized> {

unsafe impl<T> TransparentWrapper<T> for core::num::Wrapping<T> {}
#[cfg(feature = "transparentwrapper_extra")]
#[cfg_attr(
feature = "nightly_docs",
doc(cfg(feature = "transparentwrapper_extra"))
)]
unsafe impl<T> TransparentWrapper<T> for core::num::Saturating<T> {}

// Note that `Reverse` existed since Rust 1.19.0, but was only made `#[repr(transparent)]`
// in Rust 1.52.0 (PR: https://github.com/rust-lang/rust/pull/81879), so we have it under
// the same feature as `Saturating`, which was stabilized in Rust 1.74.0, so that this
// impl cannot be used on a version before 1.52.0 where it would be unsound.
#[cfg(feature = "transparentwrapper_extra")]
#[cfg_attr(
feature = "nightly_docs",
doc(cfg(feature = "transparentwrapper_extra"))
)]
unsafe impl<T> TransparentWrapper<T> for core::cmp::Reverse<T> {}
10 changes: 0 additions & 10 deletions src/zeroable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ unsafe impl<T: Zeroable> Zeroable for core::cell::UnsafeCell<T> {}
unsafe impl<T: Zeroable> Zeroable for core::cell::Cell<T> {}

#[cfg(feature = "zeroable_atomics")]
#[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "zeroable_atomics")))]
mod atomic_impls {
use super::Zeroable;

Expand Down Expand Up @@ -111,10 +110,6 @@ mod atomic_impls {
}

#[cfg(feature = "zeroable_maybe_uninit")]
#[cfg_attr(
feature = "nightly_docs",
doc(cfg(feature = "zeroable_maybe_uninit"))
)]
unsafe impl<T> Zeroable for core::mem::MaybeUninit<T> {}

unsafe impl<A: Zeroable> Zeroable for (A,) {}
Expand Down Expand Up @@ -163,7 +158,6 @@ unsafe impl<
}

#[cfg(feature = "min_const_generics")]
#[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "min_const_generics")))]
unsafe impl<T, const N: usize> Zeroable for [T; N] where T: Zeroable {}

#[cfg(not(feature = "min_const_generics"))]
Expand Down Expand Up @@ -221,10 +215,6 @@ impl_unsafe_marker_for_simd!(
);

#[cfg(feature = "nightly_portable_simd")]
#[cfg_attr(
feature = "nightly_docs",
doc(cfg(feature = "nightly_portable_simd"))
)]
unsafe impl<T, const N: usize> Zeroable for core::simd::Simd<T, N>
where
T: core::simd::SimdElement + Zeroable,
Expand Down
1 change: 0 additions & 1 deletion src/zeroable_in_option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ unsafe impl<T: ?Sized> ZeroableInOption for &'_ T {}
unsafe impl<T: ?Sized> ZeroableInOption for &'_ mut T {}

#[cfg(feature = "extern_crate_alloc")]
#[cfg_attr(feature = "nightly_docs", doc(cfg(feature = "extern_crate_alloc")))]
unsafe impl<T: ?Sized> ZeroableInOption for alloc::boxed::Box<T> {}

0 comments on commit 67d0a73

Please sign in to comment.