Skip to content

Commit 624063b

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`. It also seems to affect the new `too_long_first_doc_paragraph` lint [2], even though the documentation does not mention it. 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] Link: https://rust-lang.github.io/rust-clippy/master/index.html#/too_long_first_doc_paragraph [2] Reviewed-by: Trevor Gross <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Tested-by: Gary Guo <[email protected]> Reviewed-by: Gary Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 2f390cc commit 624063b

File tree

5 files changed

+7
-0
lines changed

5 files changed

+7
-0
lines changed

.clippy.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22

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

rust/kernel/init.rs

+1
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

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ where
5454
pub unsafe trait HasPinData {
5555
type PinData: PinData;
5656

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

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

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

rust/kernel/init/macros.rs

+1
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

+1
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)