From: John Hubbard <jhubbard@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
Alexandre Courbot <acourbot@nvidia.com>
Cc: "Joel Fernandes" <joelagnelf@nvidia.com>,
"Timur Tabi" <ttabi@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Eliot Courtney" <ecourtney@nvidia.com>,
"Shashank Sharma" <shashanks@nvidia.com>,
"Zhi Wang" <zhiw@nvidia.com>, "David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Bjorn Helgaas" <bhelgaas@google.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>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
rust-for-linux@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
"John Hubbard" <jhubbard@nvidia.com>
Subject: [PATCH v2 3/3] rust: ptr: allow clippy::incompatible_msrv for slice_ptr_len
Date: Sat, 4 Apr 2026 14:28:31 -0700 [thread overview]
Message-ID: <20260404212831.78971-4-jhubbard@nvidia.com> (raw)
In-Reply-To: <20260404212831.78971-1-jhubbard@nvidia.com>
Clippy reports four warnings when building with CLIPPY=1:
warning: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0`
--> rust/kernel/ptr/projection.rs:79:26
|
79 | if self >= slice.len() {
| ^^^^^
warning: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0`
--> rust/kernel/ptr/projection.rs:95:29
|
95 | if self.end > slice.len() {
| ^^^^^
warning: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0`
--> rust/kernel/ptr/projection.rs:121:28
|
121 | (self.start..slice.len()).get(slice)
| ^^^^^
warning: current MSRV (Minimum Supported Rust Version) is `1.78.0` but this item is stable since `1.79.0`
--> rust/kernel/ptr.rs:253:11
|
253 | p.len() * size_of::<T>()
| ^^^^^
These are false positives. The <*mut [T]>::len() and <*const [T]>::len()
methods are available because the kernel enables #![feature(slice_ptr_len)]
in lib.rs. Clippy does not account for feature gates when checking MSRV
compatibility.
Silence these false positive via #[allow(clippy::incompatible_msrv)].
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
rust/kernel/ptr.rs | 1 +
rust/kernel/ptr/projection.rs | 3 +++
2 files changed, 4 insertions(+)
diff --git a/rust/kernel/ptr.rs b/rust/kernel/ptr.rs
index bdc2d79ff669..7482653ef160 100644
--- a/rust/kernel/ptr.rs
+++ b/rust/kernel/ptr.rs
@@ -248,6 +248,7 @@ fn size(_: *const Self) -> usize {
}
impl<T> KnownSize for [T] {
+ #[allow(clippy::incompatible_msrv)]
#[inline(always)]
fn size(p: *const Self) -> usize {
p.len() * size_of::<T>()
diff --git a/rust/kernel/ptr/projection.rs b/rust/kernel/ptr/projection.rs
index 140ea8e21617..7d1c878b3116 100644
--- a/rust/kernel/ptr/projection.rs
+++ b/rust/kernel/ptr/projection.rs
@@ -74,6 +74,7 @@ fn index(self, slice: *mut T) -> *mut Self::Output {
unsafe impl<T> ProjectIndex<[T]> for usize {
type Output = T;
+ #[allow(clippy::incompatible_msrv)]
#[inline(always)]
fn get(self, slice: *mut [T]) -> Option<*mut T> {
if self >= slice.len() {
@@ -89,6 +90,7 @@ fn get(self, slice: *mut [T]) -> Option<*mut T> {
unsafe impl<T> ProjectIndex<[T]> for core::ops::Range<usize> {
type Output = [T];
+ #[allow(clippy::incompatible_msrv)]
#[inline(always)]
fn get(self, slice: *mut [T]) -> Option<*mut [T]> {
let new_len = self.end.checked_sub(self.start)?;
@@ -116,6 +118,7 @@ fn get(self, slice: *mut [T]) -> Option<*mut [T]> {
unsafe impl<T> ProjectIndex<[T]> for core::ops::RangeFrom<usize> {
type Output = [T];
+ #[allow(clippy::incompatible_msrv)]
#[inline(always)]
fn get(self, slice: *mut [T]) -> Option<*mut [T]> {
(self.start..slice.len()).get(slice)
--
2.53.0
next prev parent reply other threads:[~2026-04-04 21:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-04 21:28 [PATCH v2 0/3] Fix all clippy warnings in drm-rust-next John Hubbard
2026-04-04 21:28 ` [PATCH v2 1/3] gpu: nova-core: vbios: use from_le_bytes() for PCI ROM header parsing John Hubbard
2026-04-04 21:28 ` [PATCH v2 2/3] gpu: nova-core: fb: fix clippy::precedence warning in read_sysmem_flush_page_ga100() John Hubbard
2026-04-04 21:35 ` John Hubbard
2026-04-05 11:42 ` Alexandre Courbot
2026-04-05 12:13 ` Miguel Ojeda
2026-04-05 12:32 ` Danilo Krummrich
2026-04-06 0:38 ` Alexandre Courbot
2026-04-04 21:28 ` John Hubbard [this message]
2026-04-04 21:46 ` [PATCH v2 3/3] rust: ptr: allow clippy::incompatible_msrv for slice_ptr_len Miguel Ojeda
2026-04-04 21:49 ` John Hubbard
2026-04-05 23:22 ` Miguel Ojeda
2026-04-06 5:43 ` John Hubbard
2026-04-04 22:09 ` Gary Guo
2026-04-05 23:22 ` Miguel Ojeda
2026-04-05 15:16 ` [PATCH v2 0/3] Fix all clippy warnings in drm-rust-next Danilo Krummrich
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=20260404212831.78971-4-jhubbard@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=shashanks@nvidia.com \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=ttabi@nvidia.com \
--cc=zhiw@nvidia.com \
/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