mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Hall <jason.kei.hall@gmail.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Joe Perches <joe@perches.com>,
	Dirk Behme <dirk.behme@de.bosch.com>, Gary Guo <gary@garyguo.net>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jason Hall <jason.kei.hall@gmail.com>,
	Miguel Ojeda <ojeda@kernel.org>
Subject: [PATCH v6] scripts: checkpatch: move Rust-specific lints to separate file
Date: Sat,  7 Feb 2026 08:56:27 -0700	[thread overview]
Message-ID: <20260207155627.122810-1-jason.kei.hall@gmail.com> (raw)
In-Reply-To: <CANiq72=68-daT3J_NVvp+7NkGFWFPGQmwoXn4m54VYeRKPUkbA@mail.gmail.com>

Create scripts/rust_checkpatch.pl for Rust-specific linting logic.
Add a conditional loading hook in scripts/checkpatch.pl to call it.
This will allow Rust linting logic to be maintained independently.

Add a new entry to the MAINTAINERS file to track this new file.

Suggested-by: Joe Perches <joe@perches.com>
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-linux/linux/issues/1191
Signed-off-by: Jason Hall <jason.kei.hall@gmail.com>

---
---
 MAINTAINERS                |  6 ++++++
 scripts/rust_checkpatch.pl | 15 +++------------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2c0bdd08b74c..57831dc30e6b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5880,6 +5880,12 @@ R:	Lukas Bulwahn <lukas.bulwahn@gmail.com>
 S:	Maintained
 F:	scripts/checkpatch.pl
 
+CHECKPATCH RUST LINTS
+M:	Jason Hall <jason.kei.hall@gmail.com>
+L:	rust-for-linux@vger.kernel.org
+S:	Maintained
+F:	scripts/rust_checkpatch.pl
+
 CHECKPATCH DOCUMENTATION
 M:	Dwaipayan Ray <dwaipayanray1@gmail.com>
 M:	Lukas Bulwahn <lukas.bulwahn@gmail.com>
diff --git a/scripts/rust_checkpatch.pl b/scripts/rust_checkpatch.pl
index 69db5ded7371..56c1bc29d3f2 100644
--- a/scripts/rust_checkpatch.pl
+++ b/scripts/rust_checkpatch.pl
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 # SPDX-License-Identifier: GPL-2.0
 #
-# (c) 2026, Jason K. Hall <jason.kei.hall@gmail.com>
+# (c) 2026, Jason Hall <jason.kei.hall@gmail.com>
 
 use strict;
 use warnings;
@@ -9,17 +9,8 @@ use warnings;
 sub process_rust {
     my ($line, $rawline, $herecurr) = @_;
 
-    # check for Rust unwrap/expect
-    if ($line =~ /^\+/) {
-        if ($line =~ /(?:\.|::)(?:unwrap|expect)\s*\(/ &&
-            $rawline !~ /\/\/\s*PANIC:/ &&
-            $line !~ /^\+\s*\/\// &&
-            $line !~ /^\+\s*assert/) {
-            return ("RUST_UNWRAP",
-                    "Avoid unwrap() or expect() in Rust code; use proper error handling (Result) or justify with a '// PANIC: ...' comment.\n" . $herecurr);
-        }
-    }
+    # Reserve for future Rust-specific lints
     return ();
 }
 
-1;
\ No newline at end of file
+1;
-- 
2.43.0


  reply	other threads:[~2026-02-07 15:56 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-01 15:57 [PATCH] scripts: checkpatch: warn on Rust panicking methods Jason Hall
2026-02-01 17:19 ` Charalampos Mitrodimas
2026-02-01 18:30   ` [PATCH v2] " Jason Hall
2026-02-01 19:37     ` Joe Perches
2026-02-01 19:57   ` [PATCH v3] " Jason Hall
2026-02-02  5:38     ` Dirk Behme
2026-02-02 13:56       ` [PATCH v4] " Jason Hall
2026-02-03  6:21         ` Dirk Behme
2026-02-03 15:25           ` Jkhall81
2026-02-03 15:49             ` Onur Özkan
2026-02-03 16:02               ` Gary Guo
2026-02-03 16:32                 ` Onur Özkan
2026-02-03 16:54                   ` Gary Guo
2026-02-04 15:56                     ` Dirk Behme
2026-02-04 18:10                       ` Miguel Ojeda
2026-02-04 19:08                         ` Joe Perches
2026-02-05  1:42                           ` [PATCH v5] scripts: checkpatch: move Rust-specific lints to separate file Jason Hall
2026-02-05 20:55                             ` Miguel Ojeda
2026-02-06  8:31                               ` Dirk Behme
2026-02-06 17:41                                 ` Miguel Ojeda
2026-02-07 15:56                                   ` Jason Hall [this message]
2026-02-07 16:07                                     ` [PATCH v6] " Miguel Ojeda
2026-02-07 16:53                                       ` [PATCH v7] " Jason Hall
2026-02-07 18:46                                         ` Miguel Ojeda
2026-02-07 21:07                                           ` [PATCH v8 0/2] modularize Rust lints and add RUST_UNWRAP check Jason Hall
2026-02-07 21:07                                             ` [PATCH v8 1/2] scripts: checkpatch: move Rust-specific lints to separate file Jason Hall
2026-02-07 21:53                                               ` Miguel Ojeda
2026-02-07 22:49                                                 ` [PATCH v9 0/2] modularize Rust lints and add RUST_UNWRAP check Jason Hall
2026-02-07 22:49                                                   ` [PATCH v9 1/2] scripts: checkpatch: move Rust-specific lints to separate file Jason Hall
2026-02-07 22:49                                                   ` [PATCH v9 2/2] scripts: checkpatch: add RUST_UNWRAP lint Jason Hall
2026-02-08  7:55                                                     ` Dirk Behme
2026-02-08 14:01                                                       ` Jason Hall
2026-02-09  8:52                                                         ` Dirk Behme
2026-02-08  6:43                                                   ` [PATCH v9 0/2] modularize Rust lints and add RUST_UNWRAP check Greg KH
2026-02-14  6:11                                                   ` Dirk Behme
2026-02-14 23:30                                                     ` Miguel Ojeda
2026-02-14 23:32                                                       ` Miguel Ojeda
2026-02-07 21:07                                             ` [PATCH v8 2/2] scripts: checkpatch: add RUST_UNWRAP lint Jason Hall
2026-02-05 13:23                         ` [PATCH v4] scripts: checkpatch: warn on Rust panicking methods Dirk Behme
2026-02-05 21:00                           ` Miguel Ojeda
2026-02-04 18:11               ` Miguel Ojeda
2026-02-01 19:51 ` [PATCH] " Gary Guo

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=20260207155627.122810-1-jason.kei.hall@gmail.com \
    --to=jason.kei.hall@gmail.com \
    --cc=dirk.behme@de.bosch.com \
    --cc=gary@garyguo.net \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    /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®