Skip to content

Commit 87aa8c2

Browse files
authored
Merge pull request #101 from Rust-for-Linux/dev/doc
doc: de-clutter documentation with fake-variadics
2 parents a188482 + 530c4eb commit 87aa8c2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@
276276
all(feature = "unsafe-pinned", CONFIG_RUSTC_HAS_UNSAFE_PINNED),
277277
feature(unsafe_pinned)
278278
)]
279+
#![cfg_attr(all(USE_RUSTC_FEATURES, doc), allow(internal_features))]
280+
#![cfg_attr(all(USE_RUSTC_FEATURES, doc), feature(rustdoc_internals))]
279281

280282
use core::{
281283
cell::UnsafeCell,
@@ -1638,9 +1640,15 @@ impl_zeroable! {
16381640
}
16391641

16401642
macro_rules! impl_tuple_zeroable {
1641-
($(,)?) => {};
1643+
($first:ident, $(,)?) => {
1644+
#[cfg_attr(all(USE_RUSTC_FEATURES, doc), doc(fake_variadic))]
1645+
/// Implemented for tuples up to 10 items long.
1646+
// SAFETY: All elements are zeroable and padding can be zero.
1647+
unsafe impl<$first: Zeroable> Zeroable for ($first,) {}
1648+
};
16421649
($first:ident, $($t:ident),* $(,)?) => {
16431650
// SAFETY: All elements are zeroable and padding can be zero.
1651+
#[cfg_attr(doc, doc(hidden))]
16441652
unsafe impl<$first: Zeroable, $($t: Zeroable),*> Zeroable for ($first, $($t),*) {}
16451653
impl_tuple_zeroable!($($t),* ,);
16461654
}
@@ -1654,9 +1662,18 @@ macro_rules! impl_fn_zeroable_option {
16541662
$(impl_fn_zeroable_option!({unsafe extern $abi} $args);)*
16551663
};
16561664
({$($prefix:tt)*} {$(,)?}) => {};
1665+
({$($prefix:tt)*} {$ret:ident, $arg:ident $(,)?}) => {
1666+
#[cfg_attr(all(USE_RUSTC_FEATURES, doc), doc(fake_variadic))]
1667+
/// Implemented for function pointers with up to 20 arity.
1668+
// SAFETY: function pointers are part of the option layout optimization:
1669+
// <https://doc.rust-lang.org/stable/std/option/index.html#representation>.
1670+
unsafe impl<$ret, $arg> ZeroableOption for $($prefix)* fn($arg) -> $ret {}
1671+
impl_fn_zeroable_option!({$($prefix)*} {$arg,});
1672+
};
16571673
({$($prefix:tt)*} {$ret:ident, $($rest:ident),* $(,)?}) => {
16581674
// SAFETY: function pointers are part of the option layout optimization:
16591675
// <https://doc.rust-lang.org/stable/std/option/index.html#representation>.
1676+
#[cfg_attr(doc, doc(hidden))]
16601677
unsafe impl<$ret, $($rest),*> ZeroableOption for $($prefix)* fn($($rest),*) -> $ret {}
16611678
impl_fn_zeroable_option!({$($prefix)*} {$($rest),*,});
16621679
};

0 commit comments

Comments
 (0)