Skip to content

Commit e5d330e

Browse files
committed
rust: allow clippy::disallowed_names for doctests
Examples (i.e. doctests) may want to use names such as `foo`, thus the `clippy::disallowed_names` lint [1] gets in the way. Thus allow it for all doctests. In addition, remove it from the existing `expect`s we have in a few doctests. This does not mean that we should stop trying to find good names for our examples, though. Link: https://rust-lang.github.io/rust-clippy/stable/index.html#disallowed_names [1] Suggested-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/rust-for-linux/aRHSLChi5HYXW4-9@google.com/ Reviewed-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Benno Lossin <lossin@kernel.org> Link: https://patch.msgid.link/20251117080714.876978-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent ab844cf commit e5d330e

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed

rust/kernel/init.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//! ## General Examples
3131
//!
3232
//! ```rust
33-
//! # #![expect(clippy::disallowed_names, clippy::undocumented_unsafe_blocks)]
33+
//! # #![expect(clippy::undocumented_unsafe_blocks)]
3434
//! use kernel::types::Opaque;
3535
//! use pin_init::pin_init_from_closure;
3636
//!
@@ -67,7 +67,6 @@
6767
//! ```
6868
//!
6969
//! ```rust
70-
//! # #![expect(clippy::disallowed_names)]
7170
//! use kernel::{prelude::*, types::Opaque};
7271
//! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin};
7372
//! # mod bindings {

rust/kernel/types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ impl<T, F: FnOnce(T)> Drop for ScopeGuard<T, F> {
289289
/// # Examples
290290
///
291291
/// ```
292-
/// # #![expect(clippy::disallowed_names)]
293292
/// use kernel::types::Opaque;
294293
/// # // Emulate a C struct binding which is from C, maybe uninitialized or not, only the C side
295294
/// # // knows.

scripts/rustdoc_test_gen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub extern "C" fn {kunit_name}(__kunit_test: *mut ::kernel::bindings::kunit) {{
208208
#[allow(unused)]
209209
static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 1;
210210
{{
211-
#![allow(unreachable_pub)]
211+
#![allow(unreachable_pub, clippy::disallowed_names)]
212212
{body}
213213
main();
214214
}}

0 commit comments

Comments
 (0)