rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: remove unneeded `kernel::prelude` imports from doctests
@ 2024-04-11 22:53 Nell Shamrell-Harrington
  2024-04-12  8:48 ` Benno Lossin
  2024-05-05 22:30 ` Miguel Ojeda
  0 siblings, 2 replies; 3+ messages in thread
From: Nell Shamrell-Harrington @ 2024-04-11 22:53 UTC (permalink / raw)
  To: ojeda, alex.gaynor, wedsonaf
  Cc: boqun.feng, gary, bjorn3_gh, benno.lossin, a.hindborg, aliceryhl,
	fujita.tomonori, tmgross, yakoyoku, kent.overstreet,
	matthew.brost, kernel, netdev, rust-for-linux, linux-kernel

Rust doctests implicitly include `kernel::prelude::*`.

Removes explicit `kernel::prelude` imports from doctests.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-Linux/linux/issues/1064
Signed-off-by: Nell Shamrell-Harrington <nells@linux.microsoft.com>
---
 rust/kernel/init.rs      | 6 +++---
 rust/kernel/net/phy.rs   | 1 -
 rust/kernel/workqueue.rs | 3 ---
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
index 424257284d16..8f0380697c09 100644
--- a/rust/kernel/init.rs
+++ b/rust/kernel/init.rs
@@ -87,7 +87,7 @@
 //!
 //! ```rust
 //! # #![allow(clippy::disallowed_names)]
-//! # use kernel::{sync::Mutex, prelude::*, new_mutex, init::PinInit, try_pin_init};
+//! # use kernel::{sync::Mutex, new_mutex, init::PinInit, try_pin_init};
 //! #[pin_data]
 //! struct DriverData {
 //!     #[pin]
@@ -121,7 +121,7 @@
 //!
 //! ```rust
 //! # #![allow(unreachable_pub, clippy::disallowed_names)]
-//! use kernel::{prelude::*, init, types::Opaque};
+//! use kernel::{init, types::Opaque};
 //! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin};
 //! # mod bindings {
 //! #     #![allow(non_camel_case_types)]
@@ -412,7 +412,7 @@ macro_rules! stack_try_pin_init {
 ///
 /// ```rust
 /// # #![allow(clippy::disallowed_names)]
-/// # use kernel::{init, pin_init, prelude::*, init::*};
+/// # use kernel::{init, pin_init, init::*};
 /// # use core::pin::Pin;
 /// # #[pin_data]
 /// # struct Foo {
diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index 96e09c6e8530..d10a415c376f 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -766,7 +766,6 @@ const fn as_int(&self) -> u32 {
 /// # mod module_phy_driver_sample {
 /// use kernel::c_str;
 /// use kernel::net::phy::{self, DeviceId};
-/// use kernel::prelude::*;
 ///
 /// kernel::module_phy_driver! {
 ///     drivers: [PhySample],
diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
index c22504d5c8ad..7884f0007b38 100644
--- a/rust/kernel/workqueue.rs
+++ b/rust/kernel/workqueue.rs
@@ -33,7 +33,6 @@
 //! we do not need to specify ids for the fields.
 //!
 //! ```
-//! use kernel::prelude::*;
 //! use kernel::sync::Arc;
 //! use kernel::workqueue::{self, impl_has_work, new_work, Work, WorkItem};
 //!
@@ -75,7 +74,6 @@
 //! The following example shows how multiple `work_struct` fields can be used:
 //!
 //! ```
-//! use kernel::prelude::*;
 //! use kernel::sync::Arc;
 //! use kernel::workqueue::{self, impl_has_work, new_work, Work, WorkItem};
 //!
@@ -411,7 +409,6 @@ pub unsafe fn raw_get(ptr: *const Self) -> *mut bindings::work_struct {
 /// like this:
 ///
 /// ```no_run
-/// use kernel::prelude::*;
 /// use kernel::workqueue::{impl_has_work, Work};
 ///
 /// struct MyWorkItem {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: remove unneeded `kernel::prelude` imports from doctests
  2024-04-11 22:53 [PATCH] rust: remove unneeded `kernel::prelude` imports from doctests Nell Shamrell-Harrington
@ 2024-04-12  8:48 ` Benno Lossin
  2024-05-05 22:30 ` Miguel Ojeda
  1 sibling, 0 replies; 3+ messages in thread
From: Benno Lossin @ 2024-04-12  8:48 UTC (permalink / raw)
  To: Nell Shamrell-Harrington, ojeda, alex.gaynor, wedsonaf
  Cc: boqun.feng, gary, bjorn3_gh, a.hindborg, aliceryhl,
	fujita.tomonori, tmgross, yakoyoku, kent.overstreet,
	matthew.brost, kernel, netdev, rust-for-linux, linux-kernel

On 12.04.24 00:53, Nell Shamrell-Harrington wrote:
> Rust doctests implicitly include `kernel::prelude::*`.
> 
> Removes explicit `kernel::prelude` imports from doctests.
> 
> Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> Link: https://github.com/Rust-for-Linux/linux/issues/1064
> Signed-off-by: Nell Shamrell-Harrington <nells@linux.microsoft.com>
> ---
>  rust/kernel/init.rs      | 6 +++---
>  rust/kernel/net/phy.rs   | 1 -
>  rust/kernel/workqueue.rs | 3 ---
>  3 files changed, 3 insertions(+), 7 deletions(-)

Reviewed-by: Benno Lossin <benno.lossin@proton.me>

-- 
Cheers,
Benno


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: remove unneeded `kernel::prelude` imports from doctests
  2024-04-11 22:53 [PATCH] rust: remove unneeded `kernel::prelude` imports from doctests Nell Shamrell-Harrington
  2024-04-12  8:48 ` Benno Lossin
@ 2024-05-05 22:30 ` Miguel Ojeda
  1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2024-05-05 22:30 UTC (permalink / raw)
  To: Nell Shamrell-Harrington
  Cc: ojeda, alex.gaynor, wedsonaf, boqun.feng, gary, bjorn3_gh,
	benno.lossin, a.hindborg, aliceryhl, fujita.tomonori, tmgross,
	yakoyoku, kent.overstreet, matthew.brost, kernel, netdev,
	rust-for-linux, linux-kernel

On Fri, Apr 12, 2024 at 12:53 AM Nell Shamrell-Harrington
<nells@linux.microsoft.com> wrote:
>
> Rust doctests implicitly include `kernel::prelude::*`.
>
> Removes explicit `kernel::prelude` imports from doctests.
>
> Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> Link: https://github.com/Rust-for-Linux/linux/issues/1064
> Signed-off-by: Nell Shamrell-Harrington <nells@linux.microsoft.com>

[ Add it back for `module_phy_driver`'s example since it is within a
`mod`, and thus it cannot be removed. - Miguel ]

Nell: please double-check the above is correct (I guess you didn't
enable net/phy and thus didn't notice since it didn't get compiled?).

Applied to `rust-next` -- thanks everyone!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-05 22:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-11 22:53 [PATCH] rust: remove unneeded `kernel::prelude` imports from doctests Nell Shamrell-Harrington
2024-04-12  8:48 ` Benno Lossin
2024-05-05 22:30 ` Miguel Ojeda

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).