[PATCH v4 0/4] rust: introduce DropGuard
From: Mohamed Osama
Date: Sun Sep 27 2026 - 06:45:41 EST
This series adds the Rust kernel DropGuard API and migrates existing
cleanup guards in the block, serdev, and locking code to use it.
DropGuard is vendored from the Rust standard library and re-exported
through kernel::mem.
Changes since v3:
- Vendor DropGuard in rust/kernel/std_vendor.rs and re-export it from
kernel::mem, following Gary Guo's review.
- Remove the DropGuard KUnit tests and Kconfig option since the
implementation is vendored from the standard library.
- Keep the existing ScopeGuard API unchanged.
Testing:
- make LLVM=1 rustfmtcheck
- make LLVM=1 -j$(nproc)
Suggested-by: Gary Guo <gary@xxxxxxxxxxx>
Signed-off-by: Mohamed Osama <mohamed.osama189110@xxxxxxxxx>
Mohamed Osama (4):
rust: mem: add DropGuard
rust: block: gen_disk: use DropGuard
rust: serdev: use DropGuard
rust: sync: lock: use DropGuard
rust/kernel/block/mq/gen_disk.rs | 11 ++--
rust/kernel/mem.rs | 2 +
rust/kernel/serdev.rs | 10 ++--
rust/kernel/std_vendor.rs | 87 ++++++++++++++++++++++++++++++++
rust/kernel/sync/lock.rs | 5 +-
5 files changed, 102 insertions(+), 13 deletions(-)
--
2.43.0