Skip to content

Commit d58f0f1

Browse files
nbdd0121ojeda
authored andcommitted
rust: list: hide macros from top-level kernel doc
Due to Rust macro scoping rules, all macros defined in a crate using `#[macro_export]` end up in the top-level. For the list macros, we re-export them inside the list module, and expect users to use `kernel::list::macro_name!()`. Use `#[doc(hidden)]` on the macro definition, and use `#[doc(inline)]` on the re-export to make the macro appear to be defined at module-level inside documentation. The other exported types are already automatically `#[doc(inline)]` because they are defined in a non-public module, so there is no need to split the macro re-exports out. Signed-off-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260312174700.4016015-1-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 9bf32bc commit d58f0f1

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

rust/kernel/list.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,31 @@ use core::ptr;
1212
use pin_init::PinInit;
1313

1414
mod impl_list_item_mod;
15+
#[doc(inline)]
1516
pub use self::impl_list_item_mod::{
16-
impl_has_list_links, impl_has_list_links_self_ptr, impl_list_item, HasListLinks, HasSelfPtr,
17+
impl_has_list_links,
18+
impl_has_list_links_self_ptr,
19+
impl_list_item,
20+
HasListLinks,
21+
HasSelfPtr, //
1722
};
1823

1924
mod arc;
20-
pub use self::arc::{impl_list_arc_safe, AtomicTracker, ListArc, ListArcSafe, TryNewListArc};
25+
#[doc(inline)]
26+
pub use self::arc::{
27+
impl_list_arc_safe,
28+
AtomicTracker,
29+
ListArc,
30+
ListArcSafe,
31+
TryNewListArc, //
32+
};
2133

2234
mod arc_field;
23-
pub use self::arc_field::{define_list_arc_field_getter, ListArcField};
35+
#[doc(inline)]
36+
pub use self::arc_field::{
37+
define_list_arc_field_getter,
38+
ListArcField, //
39+
};
2440

2541
/// A linked list.
2642
///

rust/kernel/list/arc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ pub unsafe trait TryNewListArc<const ID: u64 = 0>: ListArcSafe<ID> {
8282
/// [`AtomicTracker`]. However, it is also possible to defer the tracking to another struct
8383
/// using also using this macro.
8484
#[macro_export]
85+
#[doc(hidden)]
8586
macro_rules! impl_list_arc_safe {
8687
(impl$({$($generics:tt)*})? ListArcSafe<$num:tt> for $t:ty { untracked; } $($rest:tt)*) => {
8788
impl$(<$($generics)*>)? $crate::list::ListArcSafe<$num> for $t {

rust/kernel/list/arc_field.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl<T, const ID: u64> ListArcField<T, ID> {
6666

6767
/// Defines getters for a [`ListArcField`].
6868
#[macro_export]
69+
#[doc(hidden)]
6970
macro_rules! define_list_arc_field_getter {
7071
($pub:vis fn $name:ident(&self $(<$id:tt>)?) -> &$typ:ty { $field:ident }
7172
$($rest:tt)*

rust/kernel/list/impl_list_item_mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub unsafe trait HasListLinks<const ID: u64 = 0> {
2929

3030
/// Implements the [`HasListLinks`] trait for the given type.
3131
#[macro_export]
32+
#[doc(hidden)]
3233
macro_rules! impl_has_list_links {
3334
($(impl$({$($generics:tt)*})?
3435
HasListLinks$(<$id:tt>)?
@@ -74,6 +75,7 @@ where
7475

7576
/// Implements the [`HasListLinks`] and [`HasSelfPtr`] traits for the given type.
7677
#[macro_export]
78+
#[doc(hidden)]
7779
macro_rules! impl_has_list_links_self_ptr {
7880
($(impl$({$($generics:tt)*})?
7981
HasSelfPtr<$item_type:ty $(, $id:tt)?>
@@ -181,6 +183,7 @@ pub use impl_has_list_links_self_ptr;
181183
/// }
182184
/// ```
183185
#[macro_export]
186+
#[doc(hidden)]
184187
macro_rules! impl_list_item {
185188
(
186189
$(impl$({$($generics:tt)*})? ListItem<$num:tt> for $self:ty {

0 commit comments

Comments
 (0)