* [PATCH 1/2] rust: init: re-enable doctests
@ 2025-05-26 15:29 Miguel Ojeda
2025-05-26 15:29 ` [PATCH 2/2] rust: init: remove doctest's `Error::from_errno` workaround Miguel Ojeda
2025-06-09 19:54 ` [PATCH 1/2] rust: init: re-enable doctests Benno Lossin
0 siblings, 2 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-05-26 15:29 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor
Cc: rust-for-linux, Boqun Feng, Gary Guo, Björn Roy Baron,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
linux-kernel, patches
Commit a30e94c29673 ("rust: init: make doctests compilable/testable")
made these tests buildable among others, but eventually the pin-init
crate was made into its own crate [1] and the tests were marked as
`ignore` in commit 206dea39e559 ("rust: init: disable doctests").
A few other bits got changed in that reorganization, e.g. the
`clippy::missing_safety_doc` was removed and the `expect` use.
Since there is no reason not to build/test them, re-enable them.
In order to do so, tweak a few bits to keep the build clean, and also use
again `expect` since this is one of those places where we can actually
do so.
Link: https://lore.kernel.org/all/20250308110339.2997091-1-benno.lossin@proton.me/ [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
rust/kernel/init.rs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
index 8d228c237954..78cadfcd4392 100644
--- a/rust/kernel/init.rs
+++ b/rust/kernel/init.rs
@@ -29,15 +29,15 @@
//!
//! ## General Examples
//!
-//! ```rust,ignore
-//! # #![allow(clippy::disallowed_names)]
+//! ```rust
+//! # #![expect(clippy::disallowed_names, clippy::undocumented_unsafe_blocks)]
//! use kernel::types::Opaque;
//! use pin_init::pin_init_from_closure;
//!
//! // assume we have some `raw_foo` type in C:
//! #[repr(C)]
//! struct RawFoo([u8; 16]);
-//! extern {
+//! extern "C" {
//! fn init_foo(_: *mut RawFoo);
//! }
//!
@@ -66,12 +66,12 @@
//! });
//! ```
//!
-//! ```rust,ignore
-//! # #![allow(unreachable_pub, clippy::disallowed_names)]
+//! ```rust
+//! # #![expect(unreachable_pub, clippy::disallowed_names)]
//! use kernel::{prelude::*, types::Opaque};
//! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin};
//! # mod bindings {
-//! # #![allow(non_camel_case_types)]
+//! # #![expect(non_camel_case_types, clippy::missing_safety_doc)]
//! # pub struct foo;
//! # pub unsafe fn init_foo(_ptr: *mut foo) {}
//! # pub unsafe fn destroy_foo(_ptr: *mut foo) {}
base-commit: f4daa80d6be7d3c55ca72a8e560afc4e21f886aa
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] rust: init: remove doctest's `Error::from_errno` workaround
2025-05-26 15:29 [PATCH 1/2] rust: init: re-enable doctests Miguel Ojeda
@ 2025-05-26 15:29 ` Miguel Ojeda
2025-06-09 19:54 ` [PATCH 1/2] rust: init: re-enable doctests Benno Lossin
1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-05-26 15:29 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor
Cc: rust-for-linux, Boqun Feng, Gary Guo, Björn Roy Baron,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
linux-kernel, patches
Since commit 5ed147473458 ("rust: error: make conversion functions
public"), `Error::from_errno` is public.
Thus remove the workaround added in commit a30e94c29673 ("rust: init:
make doctests compilable/testable").
Suggested-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
rust/kernel/init.rs | 8 --------
1 file changed, 8 deletions(-)
diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
index 78cadfcd4392..e57a30a5d20c 100644
--- a/rust/kernel/init.rs
+++ b/rust/kernel/init.rs
@@ -77,14 +77,6 @@
//! # pub unsafe fn destroy_foo(_ptr: *mut foo) {}
//! # pub unsafe fn enable_foo(_ptr: *mut foo, _flags: u32) -> i32 { 0 }
//! # }
-//! # // `Error::from_errno` is `pub(crate)` in the `kernel` crate, thus provide a workaround.
-//! # trait FromErrno {
-//! # fn from_errno(errno: core::ffi::c_int) -> Error {
-//! # // Dummy error that can be constructed outside the `kernel` crate.
-//! # Error::from(core::fmt::Error)
-//! # }
-//! # }
-//! # impl FromErrno for Error {}
//! /// # Invariants
//! ///
//! /// `foo` is always initialized
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] rust: init: re-enable doctests
2025-05-26 15:29 [PATCH 1/2] rust: init: re-enable doctests Miguel Ojeda
2025-05-26 15:29 ` [PATCH 2/2] rust: init: remove doctest's `Error::from_errno` workaround Miguel Ojeda
@ 2025-06-09 19:54 ` Benno Lossin
1 sibling, 0 replies; 3+ messages in thread
From: Benno Lossin @ 2025-06-09 19:54 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor
Cc: rust-for-linux, Boqun Feng, Gary Guo, Björn Roy Baron,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
linux-kernel, patches
On Mon May 26, 2025 at 5:29 PM CEST, Miguel Ojeda wrote:
> Commit a30e94c29673 ("rust: init: make doctests compilable/testable")
> made these tests buildable among others, but eventually the pin-init
> crate was made into its own crate [1] and the tests were marked as
> `ignore` in commit 206dea39e559 ("rust: init: disable doctests").
>
> A few other bits got changed in that reorganization, e.g. the
> `clippy::missing_safety_doc` was removed and the `expect` use.
>
> Since there is no reason not to build/test them, re-enable them.
>
> In order to do so, tweak a few bits to keep the build clean, and also use
> again `expect` since this is one of those places where we can actually
> do so.
>
> Link: https://lore.kernel.org/all/20250308110339.2997091-1-benno.lossin@proton.me/ [1]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> rust/kernel/init.rs | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
Applied both to pin-init-next -- thanks everyone!
---
Cheers,
Benno
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-09 19:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-26 15:29 [PATCH 1/2] rust: init: re-enable doctests Miguel Ojeda
2025-05-26 15:29 ` [PATCH 2/2] rust: init: remove doctest's `Error::from_errno` workaround Miguel Ojeda
2025-06-09 19:54 ` [PATCH 1/2] rust: init: re-enable doctests Benno Lossin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).