[PATCH v2 1/2] rust: init: compile examples

Tamir Duberstein posted 2 patches 5 months, 1 week ago
[PATCH v2 1/2] rust: init: compile examples
Posted by Tamir Duberstein 5 months, 1 week ago
It's not exactly clear to me why these were `ignore`d. There are many
others like this in pin-init, but I'm only touching the kernel-specific
ones here.

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 rust/kernel/init.rs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
index 8d228c237954..f8402c818d30 100644
--- a/rust/kernel/init.rs
+++ b/rust/kernel/init.rs
@@ -29,15 +29,16 @@
 //!
 //! ## General Examples
 //!
-//! ```rust,ignore
+//! ```rust
 //! # #![allow(clippy::disallowed_names)]
+//! # #![allow(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 +67,13 @@
 //! });
 //! ```
 //!
-//! ```rust,ignore
+//! ```rust
 //! # #![allow(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)]
+//! #     #![allow(clippy::missing_safety_doc)]
 //! #     pub struct foo;
 //! #     pub unsafe fn init_foo(_ptr: *mut foo) {}
 //! #     pub unsafe fn destroy_foo(_ptr: *mut foo) {}

-- 
2.50.0
Re: [PATCH v2 1/2] rust: init: compile examples
Posted by Miguel Ojeda 5 months ago
On Thu, Jul 10, 2025 at 12:49 AM Tamir Duberstein <tamird@gmail.com> wrote:
>
> It's not exactly clear to me why these were `ignore`d. There are many
> others like this in pin-init, but I'm only touching the kernel-specific
> ones here.
>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>

This seems essentially equivalent to this one applied a few weeks ago:

    https://lore.kernel.org/rust-for-linux/20250526152914.2453949-1-ojeda@kernel.org/

But that one uses `expect` to, which is a bit better for the future.

Cheers,
Miguel
Re: [PATCH v2 1/2] rust: init: compile examples
Posted by Tamir Duberstein 5 months ago
On Sun, Jul 13, 2025 at 4:33 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Thu, Jul 10, 2025 at 12:49 AM Tamir Duberstein <tamird@gmail.com> wrote:
> >
> > It's not exactly clear to me why these were `ignore`d. There are many
> > others like this in pin-init, but I'm only touching the kernel-specific
> > ones here.
> >
> > Signed-off-by: Tamir Duberstein <tamird@gmail.com>
>
> This seems essentially equivalent to this one applied a few weeks ago:
>
>     https://lore.kernel.org/rust-for-linux/20250526152914.2453949-1-ojeda@kernel.org/
>
> But that one uses `expect` to, which is a bit better for the future.

Yep, thanks!
Re: [PATCH v2 1/2] rust: init: compile examples
Posted by Benno Lossin 5 months ago
On Thu Jul 10, 2025 at 12:49 AM CEST, Tamir Duberstein wrote:
> It's not exactly clear to me why these were `ignore`d. There are many
> others like this in pin-init, but I'm only touching the kernel-specific
> ones here.

Most likely a remnant from 206dea39e559 ("rust: init: disable doctests")
that wasn't cleaned up... Thanks!

---
Cheers,
Benno

> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> ---
>  rust/kernel/init.rs | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)