[PATCH v2 3/3] rust: ptr: allow clippy::incompatible_msrv for slice_ptr_len
From: John Hubbard
Date: Sat Apr 04 2026 - 17:30:15 EST
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@xxxxxxxxxx>
---
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