rust: init: remove old workaround
Subsystems (2)
v2 cover rust: init: remove old workaround
The first patch just enables compilation for these doctests, since I accidentally broke them in v1 of the second patch.
---
Changes in v2:
- Add a commit to compile the doctests.
- Remove a bit more.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Tamir Duberstein (2):
rust: init: compile examples
rust: init: remove old workaround
rust/kernel/init.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
---
base-commit: 2009a2d5696944d85c34d75e691a6f3884e787c0
change-id: 20250709-init-remove-old-workaround-a6ec6792e010
Best regards,
Signature · 1 line
Tamir Duberstein <[email protected]>
PATCH v2 1/2 rust: init: compile examples
It's not exactly clear to me why these were ignored. There are many others like this in pin-init, but I'm only touching the kernel-specific ones here.
--- rust/kernel/init.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
rust/kernel/init.rs +5 -3
@@ -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) {}
Signature · 1 line
2.50.0
Benno Lossin
maintainerRe: [PATCH v2 1/2] rust: init: compile examples
Quoted 3 lines · Tamir Duberstein
It's not exactly clear to me why these were
ignored. 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
Quoted 4 lines
Signed-off-by Tamir Duberstein <[email protected]>--- rust/kernel/init.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Re: [PATCH v2 1/2] rust: init: compile examples
In reply to Tamir DubersteinQuoted 6 lines · Tamir Duberstein
It's not exactly clear to me why these were
ignored. There are many others like this in pin-init, but I'm only touching the kernel-specific ones here.Signed-off-by Tamir Duberstein <[email protected]>
This seems essentially equivalent to this one applied a few weeks ago:
https://lore.kernel.org/rust-for-linux/[email protected]/
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
Quoted 7 lines · Miguel Ojeda
Quoted 5 lines · Tamir Duberstein
It's not exactly clear to me why these were
ignored. There are many others like this in pin-init, but I'm only touching the kernel-specific ones here.
Quoted 7 lines
Quoted 1 line
Signed-off-by Tamir Duberstein <[email protected]>This seems essentially equivalent to this one applied a few weeks ago:
https://lore.kernel.org/rust-for-linux/[email protected]/But that one uses
expectto, which is a bit better for the future.
Yep, thanks!
PATCH v2 2/2 rust: init: remove old workaround
In reply to Tamir DubersteinError::from_errno is pub since commit 5ed147473458 ("rust: error:
make conversion functions public"), thus remove this workaround which is no longer needed.
--- rust/kernel/init.rs | 8 -------- 1 file changed, 8 deletions(-)
rust/kernel/init.rs +0 -8
@@ -79,14 +79,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
Signature · 1 line
2.50.0
Quoted 6 lines · Tamir Duberstein
Error::from_errnoispubsince commit5ed147473458("rust: error:
make conversion functions public"), thus remove this workaround which is no longer needed.Signed-off-by Tamir Duberstein <[email protected]>
This seems the same as this one applied a few weeks ago:
https://lore.kernel.org/rust-for-linux/[email protected]/
Cheers,
Miguel
Benno Lossin
maintainerQuoted 11 lines · Miguel Ojeda
Quoted 6 lines · Tamir Duberstein
Error::from_errnoispubsince commit5ed147473458("rust: error:
make conversion functions public"), thus remove this workaround which is no longer needed.Signed-off-by Tamir Duberstein <[email protected]>This seems the same as this one applied a few weeks ago:
https://lore.kernel.org/rust-for-linux/[email protected]/
Oh yeah you're right, thanks for the heads-up! (seems like I forgot the patches after applying them so early in the cycle :)
---
Cheers,
Benno