rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: id_pool: fix example
@ 2025-12-01  0:09 Miguel Ojeda
  2025-12-01 10:07 ` Alice Ryhl
  2025-12-01 19:28 ` Yury Norov
  0 siblings, 2 replies; 6+ messages in thread
From: Miguel Ojeda @ 2025-12-01  0:09 UTC (permalink / raw)
  To: Alice Ryhl, Burak Emir, Miguel Ojeda, Alex Gaynor
  Cc: Yury Norov, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich,
	rust-for-linux, linux-kernel, patches

When building with KUnit doctests enabled, `rustc` reports:

    error[E0599]: no method named `acquire_next_id` found for struct `IdPool` in the current scope
        --> rust/doctests_kernel_generated.rs:6722:24
         |
    6722 |     assert_eq!(i, pool.acquire_next_id(i).ok_or(ENOSPC)?);
         |                        ^^^^^^^^^^^^^^^ method not found in `IdPool`

Thus fix it.

Fixes: a5726454470c ("rust: id_pool: do not immediately acquire new ids")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
I saw this in -next.

 rust/kernel/id_pool.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/id_pool.rs b/rust/kernel/id_pool.rs
index 73a952d7dd83..384753fe0e44 100644
--- a/rust/kernel/id_pool.rs
+++ b/rust/kernel/id_pool.rs
@@ -28,7 +28,7 @@
 ///
 /// let mut pool = IdPool::with_capacity(64, GFP_KERNEL)?;
 /// for i in 0..64 {
-///     assert_eq!(i, pool.acquire_next_id(i).ok_or(ENOSPC)?);
+///     assert_eq!(i, pool.find_unused_id(i).ok_or(ENOSPC)?.acquire());
 /// }
 ///
 /// pool.release_id(23);

base-commit: 00c5ce039598e692e1dd4bf2b3ad5bc08bdf3270
--
2.52.0

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

end of thread, other threads:[~2025-12-02 18:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-01  0:09 [PATCH] rust: id_pool: fix example Miguel Ojeda
2025-12-01 10:07 ` Alice Ryhl
2025-12-01 19:28 ` Yury Norov
2025-12-01 23:13   ` Miguel Ojeda
2025-12-02 12:22     ` Alice Ryhl
2025-12-02 18:33       ` Yury Norov

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