From: Benno Lossin <benno.lossin@proton.me>
To: "Arnaud Lecomte" <contact@arnaud-lcm.com>,
"Andy Whitcroft" <apw@canonical.com>,
"Joe Perches" <joe@perches.com>,
"Dwaipayan Ray" <dwaipayanray1@gmail.com>,
"Lukas Bulwahn" <lukas.bulwahn@gmail.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>
Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
llvm@lists.linux.dev, skhan@linuxfoundation.org
Subject: Re: [PATCH 0/2] checkpatch.pl: add warning for // comments on private Rust items
Date: Sun, 20 Apr 2025 08:15:24 +0000 [thread overview]
Message-ID: <D9BBEQHO1XMG.2C5Q7FF02BDLJ@proton.me> (raw)
In-Reply-To: <20250419-checkpatch-rust-private-item-comment-v1-0-0f8bc109bd5a@arnaud-lcm.com>
On Sat Apr 19, 2025 at 10:24 PM CEST, Arnaud Lecomte wrote:
> Hi,
>
> Background
> ----------
>
> The Rust-for-Linux project currently lacks enforcement of documentation for private Rust items,
> as highlighted in https://github.com/Rust-for-Linux/linux/issues/1157.
> While rustc already lints missing documentation for public items, private items remain unchecked.
> This patch series aims to close that gap by ensuring proper documentation practices
> for private Rust items in the kernel.
> As underlined in this issue:
> https://github.com/Rust-for-Linux/linux/issues/1157, the purposes of
> this patch serie is to ensure the proper documentation of private rust
> items. Public items missing documentation are already linted by rustc.
>
> The actual solution comes in several parts
> ------------------------------------------
>
> 1) Patch 1 : Implements detection logic to emit warnings for improperly
> documented private Rust items (e.g., // comments instead of ///).
> 2) Patch 2 : Adds an auto-fix mechanism via the --fix option to help
> developers correct documentation issues.
>
> Results
> --------------------
Thanks for this helpful example, I'd recommend you to run your modified
version on real patches from the list and/or on already existing commits
in the kernel.
>
> The following implementation has been tested against this input file:
> // SPDX-License-Identifier: GPL-2.0
[...]
> pub struct Point2D {
> pub x: f32,
> pub y: f32
> }
>
> mod test_module {
> // Module inner comment - should not trigger
> }
>
> // Comment before macro - should not trigger
> macro_rules! my_macro {
I think we should also trigger this for macros. All macros are private
by default and only made public with the `#[macro_export]` annotation.
> // Comment inside macro - should not trigger
> () => {};
> }
>
> // Comment before unsafe block - should not trigger
> unsafe {
> // Comment inside unsafe block - should not trigger
> let x = 5;
> }
>
> // Comment with unsafe word - should trigger
> fn with_unsafe_keyword() {
> println!("test");
> }
>
> // Comment with code example: - should trigger
> // let x = 5; - should trigger
Code examples are usually wrapped in '```', so they are another
indicator that it probably should be a doc-comment.
> fn with_code_example() {
> println!("test");
> }
>
> // NOTE: important consideration - should not trigger
> fn note_marker() -> bool {
> true
> }
>
> // Comment with code example: - should trigger
I'm not 100% convinced that this should trigger. We have several cases
of the following (in some cases the function is public, I don't
remember if we have a private case):
/// Normal function docs...
// We probably should refactor XYZ.
fn foo() {}
There it should not trigger.
---
Cheers,
Benno
> /// let x = 5; - should not trigger
> fn with_mixed_comments() {
> println!("test");
> }
next prev parent reply other threads:[~2025-04-20 8:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-19 20:24 Arnaud Lecomte
2025-04-19 21:24 ` [PATCH 1/2] checkpatch.pl: warn about " Arnaud Lecomte
2025-04-19 22:25 ` [PATCH 2/2] checkpatch.pl: add `--fix` support for `//` " Arnaud Lecomte
2025-04-20 8:15 ` Benno Lossin [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-04-19 19:20 [PATCH 0/2] checkpatch.pl: add warning for // " Arnaud Lecomte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D9BBEQHO1XMG.2C5Q7FF02BDLJ@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=apw@canonical.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=contact@arnaud-lcm.com \
--cc=dakr@kernel.org \
--cc=dwaipayanray1@gmail.com \
--cc=gary@garyguo.net \
--cc=joe@perches.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=lukas.bulwahn@gmail.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®