From 3b17c48516a6bab424c3dd77e3684de56828fef8 Mon Sep 17 00:00:00 2001 From: Patrick Miller Date: Thu, 5 Sep 2024 16:07:25 -0400 Subject: [PATCH 1/2] docs: rust: make section names plural --- rust/kernel/init.rs | 2 +- rust/kernel/list/arc.rs | 2 +- rust/kernel/sync/arc.rs | 2 +- rust/macros/lib.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs index a17ac8762d8f9f..98889ddf982825 100644 --- a/rust/kernel/init.rs +++ b/rust/kernel/init.rs @@ -746,7 +746,7 @@ macro_rules! try_init { /// Asserts that a field on a struct using `#[pin_data]` is marked with `#[pin]` ie. that it is /// structurally pinned. /// -/// # Example +/// # Examples /// /// This will succeed: /// ``` diff --git a/rust/kernel/list/arc.rs b/rust/kernel/list/arc.rs index d801b9dc6291db..611ce07cd29054 100644 --- a/rust/kernel/list/arc.rs +++ b/rust/kernel/list/arc.rs @@ -464,7 +464,7 @@ where /// A utility for tracking whether a [`ListArc`] exists using an atomic. /// -/// # Invariant +/// # Invariants /// /// If the boolean is `false`, then there is no [`ListArc`] for this value. #[repr(transparent)] diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs index 3021f30fd822f6..3d3c100b0c0dfa 100644 --- a/rust/kernel/sync/arc.rs +++ b/rust/kernel/sync/arc.rs @@ -436,7 +436,7 @@ impl From>> for Arc { /// There are no mutable references to the underlying [`Arc`], and it remains valid for the /// lifetime of the [`ArcBorrow`] instance. /// -/// # Example +/// # Examples /// /// ``` /// use kernel::sync::{Arc, ArcBorrow}; diff --git a/rust/macros/lib.rs b/rust/macros/lib.rs index a626b1145e5c4f..3879e116286637 100644 --- a/rust/macros/lib.rs +++ b/rust/macros/lib.rs @@ -307,7 +307,7 @@ pub fn pinned_drop(args: TokenStream, input: TokenStream) -> TokenStream { /// literals (lifetimes and documentation strings are not supported). There is a difference in /// supported modifiers as well. /// -/// # Example +/// # Examples /// /// ```ignore /// use kernel::macro::paste; From d32fc70f9c00e62d09d463f96ae0bb55aca1c10e Mon Sep 17 00:00:00 2001 From: Patrick Miller Date: Fri, 6 Sep 2024 13:34:33 -0400 Subject: [PATCH 2/2] checkpatch: warn on known non-plural rust doc headers --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 39032224d504f1..cb5ecdb6df9bdd 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3900,6 +3900,13 @@ sub process { "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/core-api/asm-annotations.rst\n" . $herecurr); } +# check that document section headers are plural in rust files + if ($realfile =~ /\.rs$/ + && $rawline =~ /^\+\s*\/\/\/\s+#+\s+(Example|Invariant|Guarantee|Panic)\s*$/) { + WARN( "RUST_DOC_HEADER", + "Rust doc headers should be plural\n" . $herecurr ); + } + # check we are in a valid source file C or perl if not then ignore this hunk next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);