linux/rust/kernel/sync
Jason Devers 99214efede rust: sync: Add #[must_use] to Lock::try_lock()
The `Lock::try_lock()` function returns an `Option<Guard<...>>`, but it
currently does not issue a warning if the return value is unused.
To avoid potential bugs, the `#[must_use]` annotation is added to ensure
proper usage.

Note that `T` is `#[must_use]` but `Option<T>` is not.
For more context, see: https://github.com/rust-lang/rust/issues/71368.

Suggested-by: Alice Ryhl <aliceryhl@google.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1133
Signed-off-by: Jason Devers <dev.json2@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20241212154753.139563-1-dev.json2@gmail.com
2025-07-11 15:11:54 -07:00
..
arc rust: provide proper code documentation titles 2024-10-07 21:39:57 +02:00
lock Rust changes for v6.15 2025-03-30 17:03:26 -07:00
arc.rs rust: make section names plural 2025-05-26 18:03:09 +02:00
condvar.rs Rust changes for v6.15 2025-03-30 17:03:26 -07:00
lock.rs rust: sync: Add #[must_use] to Lock::try_lock() 2025-07-11 15:11:54 -07:00
locked_by.rs rust: sync: add missing newline in locked_by log example 2025-03-06 20:44:06 +01:00
poll.rs Rust changes for v6.15 2025-03-30 17:03:26 -07:00
rcu.rs rust: sync: rcu: Mark Guard methods as inline 2025-05-16 09:00:54 -04:00