diff --git a/src/cfgs.rs b/src/cfgs.rs index 6dc6c47e..6722b980 100644 --- a/src/cfgs.rs +++ b/src/cfgs.rs @@ -1,5 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT +#![allow(missing_docs)] + #[cfg(not(all( portable_atomic_no_atomic_load_store, not(any( @@ -12,20 +14,26 @@ )))] #[macro_use] mod atomic_8_16_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_8 { ($($tt:tt)*) => { $($tt)* }; } - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) + #[macro_export] + macro_rules! cfg_no_atomic_8 { + ($($tt:tt)*) => {}; + } #[macro_export] macro_rules! cfg_has_atomic_16 { ($($tt:tt)*) => { $($tt)* }; } + #[macro_export] + macro_rules! cfg_no_atomic_16 { + ($($tt:tt)*) => {}; + } } #[cfg(all( portable_atomic_no_atomic_load_store, @@ -39,16 +47,26 @@ mod atomic_8_16_macros { ))] #[macro_use] mod atomic_8_16_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_8 { ($($tt:tt)*) => {}; } - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) + #[macro_export] + macro_rules! cfg_no_atomic_8 { + ($($tt:tt)*) => { + $($tt)* + }; + } #[macro_export] macro_rules! cfg_has_atomic_16 { ($($tt:tt)*) => {}; } + #[macro_export] + macro_rules! cfg_no_atomic_16 { + ($($tt:tt)*) => { + $($tt)* + }; + } } #[cfg(all( @@ -66,13 +84,16 @@ mod atomic_8_16_macros { ))] #[macro_use] mod atomic_32_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_32 { ($($tt:tt)*) => { $($tt)* }; } + #[macro_export] + macro_rules! cfg_no_atomic_32 { + ($($tt:tt)*) => {}; + } } #[cfg(not(all( any(not(target_pointer_width = "16"), feature = "fallback"), @@ -89,11 +110,16 @@ mod atomic_32_macros { )))] #[macro_use] mod atomic_32_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_32 { ($($tt:tt)*) => {}; } + #[macro_export] + macro_rules! cfg_no_atomic_32 { + ($($tt:tt)*) => { + $($tt)* + }; + } } #[cfg_attr( @@ -132,13 +158,16 @@ mod atomic_32_macros { )] #[macro_use] mod atomic_64_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_64 { ($($tt:tt)*) => { $($tt)* }; } + #[macro_export] + macro_rules! cfg_no_atomic_64 { + ($($tt:tt)*) => {}; + } } #[cfg_attr( portable_atomic_no_cfg_target_has_atomic, @@ -176,11 +205,16 @@ mod atomic_64_macros { )] #[macro_use] mod atomic_64_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_64 { ($($tt:tt)*) => {}; } + #[macro_export] + macro_rules! cfg_no_atomic_64 { + ($($tt:tt)*) => { + $($tt)* + }; + } } #[cfg_attr( @@ -258,13 +292,16 @@ mod atomic_64_macros { )] #[macro_use] mod atomic_128_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_128 { ($($tt:tt)*) => { $($tt)* }; } + #[macro_export] + macro_rules! cfg_no_atomic_128 { + ($($tt:tt)*) => {}; + } } #[cfg_attr( not(feature = "fallback"), @@ -341,11 +378,16 @@ mod atomic_128_macros { )] #[macro_use] mod atomic_128_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_128 { ($($tt:tt)*) => {}; } + #[macro_export] + macro_rules! cfg_no_atomic_128 { + ($($tt:tt)*) => { + $($tt)* + }; + } } #[cfg_attr( @@ -370,13 +412,16 @@ mod atomic_128_macros { )] #[macro_use] mod atomic_cas_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_cas { ($($tt:tt)*) => { $($tt)* }; } + #[macro_export] + macro_rules! cfg_no_atomic_cas { + ($($tt:tt)*) => {}; + } } #[cfg_attr( portable_atomic_no_cfg_target_has_atomic, @@ -400,9 +445,37 @@ mod atomic_cas_macros { )] #[macro_use] mod atomic_cas_macros { - #[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[macro_export] macro_rules! cfg_has_atomic_cas { ($($tt:tt)*) => {}; } + #[macro_export] + macro_rules! cfg_no_atomic_cas { + ($($tt:tt)*) => { + $($tt)* + }; + } +} + +// Check that all cfg_ macros work. +mod check { + crate::cfg_has_atomic_8! { type _Atomic8 = (); } + crate::cfg_no_atomic_8! { type _Atomic8 = (); } + crate::cfg_has_atomic_16! { type _Atomic16 = (); } + crate::cfg_no_atomic_16! { type _Atomic16 = (); } + crate::cfg_has_atomic_32! { type _Atomic32 = (); } + crate::cfg_no_atomic_32! { type _Atomic32 = (); } + crate::cfg_has_atomic_64! { type _Atomic64 = (); } + crate::cfg_no_atomic_64! { type _Atomic64 = (); } + crate::cfg_has_atomic_128! { type _Atomic128 = (); } + crate::cfg_no_atomic_128! { type _Atomic128 = (); } + crate::cfg_has_atomic_ptr! { type _AtomicPtr = (); } + crate::cfg_no_atomic_ptr! { type _AtomicPtr = (); } + crate::cfg_has_atomic_cas! { type __AtomicPtr = (); } + crate::cfg_no_atomic_cas! { type __AtomicPtr = (); } + #[allow(unused_imports)] + use { + _Atomic128 as _, _Atomic16 as _, _Atomic32 as _, _Atomic64 as _, _Atomic8 as _, + _AtomicPtr as _, __AtomicPtr as _, + }; } diff --git a/src/lib.rs b/src/lib.rs index 3268ba1a..b13aca83 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -200,7 +200,7 @@ RUSTFLAGS="--cfg portable_atomic_no_outline_atomics" cargo ... #![warn( // Lints that may help when writing public library. missing_debug_implementations, - missing_docs, + // missing_docs, clippy::alloc_instead_of_core, clippy::exhaustive_enums, clippy::exhaustive_structs, @@ -209,6 +209,7 @@ RUSTFLAGS="--cfg portable_atomic_no_outline_atomics" cargo ... clippy::std_instead_of_alloc, clippy::std_instead_of_core, )] +#![cfg_attr(not(portable_atomic_no_asm), warn(missing_docs))] // module-level #![allow(missing_docs)] doesn't work for macros on old rustc #![allow( clippy::cast_lossless, clippy::inline_always, @@ -441,18 +442,14 @@ extern crate std; #[macro_use] mod cfgs; -#[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) #[cfg(target_pointer_width = "128")] -pub use cfg_has_atomic_128 as cfg_has_atomic_ptr; -#[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) +pub use {cfg_has_atomic_128 as cfg_has_atomic_ptr, cfg_no_atomic_128 as cfg_no_atomic_ptr}; #[cfg(target_pointer_width = "16")] -pub use cfg_has_atomic_16 as cfg_has_atomic_ptr; -#[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) +pub use {cfg_has_atomic_16 as cfg_has_atomic_ptr, cfg_no_atomic_16 as cfg_no_atomic_ptr}; #[cfg(target_pointer_width = "32")] -pub use cfg_has_atomic_32 as cfg_has_atomic_ptr; -#[doc(hidden)] // Not public API. (please submit an issue if you want this to be public API) +pub use {cfg_has_atomic_32 as cfg_has_atomic_ptr, cfg_no_atomic_32 as cfg_no_atomic_ptr}; #[cfg(target_pointer_width = "64")] -pub use cfg_has_atomic_64 as cfg_has_atomic_ptr; +pub use {cfg_has_atomic_64 as cfg_has_atomic_ptr, cfg_no_atomic_64 as cfg_no_atomic_ptr}; #[macro_use] mod utils;