Skip to content

Commit 5d9a42a

Browse files
committed
rust: enable Clippy's check-private-items
In Rust 1.76.0, Clippy added the `check-private-items` lint configuration option. When turned on (the default is off), it makes several lints check private items as well. In our case, it affects two lints we have enabled [1]: `missing_safety_doc` and `unnecessary_safety_doc`. Thus allow the few instances remaining we currently hit and enable the lint. Link: https://doc.rust-lang.org/nightly/clippy/lint_configuration.html#check-private-items [1] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 8ce9f5a commit 5d9a42a

File tree

5 files changed

+7
-0
lines changed

5 files changed

+7
-0
lines changed

.clippy.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
msrv = "1.78.0"
44

5+
check-private-items = true
6+
57
disallowed-macros = [
68
# The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate
79
# it here, see: https://github.com/rust-lang/rust-clippy/issues/11303.

rust/kernel/init.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
//! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin};
126126
//! # mod bindings {
127127
//! # #![allow(non_camel_case_types)]
128+
//! # #![allow(clippy::missing_safety_doc)]
128129
//! # pub struct foo;
129130
//! # pub unsafe fn init_foo(_ptr: *mut foo) {}
130131
//! # pub unsafe fn destroy_foo(_ptr: *mut foo) {}

rust/kernel/init/__internal.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ where
5353
pub unsafe trait HasPinData {
5454
type PinData: PinData;
5555

56+
#[allow(clippy::missing_safety_doc)]
5657
unsafe fn __pin_data() -> Self::PinData;
5758
}
5859

@@ -82,6 +83,7 @@ pub unsafe trait PinData: Copy {
8283
pub unsafe trait HasInitData {
8384
type InitData: InitData;
8485

86+
#[allow(clippy::missing_safety_doc)]
8587
unsafe fn __init_data() -> Self::InitData;
8688
}
8789

rust/kernel/init/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ macro_rules! __pin_data {
989989
//
990990
// The functions are `unsafe` to prevent accidentally calling them.
991991
#[allow(dead_code)]
992+
#[allow(clippy::missing_safety_doc)]
992993
impl<$($impl_generics)*> $pin_data<$($ty_generics)*>
993994
where $($whr)*
994995
{

rust/kernel/print.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use core::{
1414
use crate::str::RawFormatter;
1515

1616
// Called from `vsprintf` with format specifier `%pA`.
17+
#[allow(clippy::missing_safety_doc)]
1718
#[no_mangle]
1819
unsafe extern "C" fn rust_fmt_argument(
1920
buf: *mut c_char,

0 commit comments

Comments
 (0)