diff options
author | Benno Lossin <benno.lossin@proton.me> | 2023-08-14 11:46:48 +0300 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2023-08-21 15:31:48 +0300 |
commit | 97de919d574e6a22f0d43a169b96274f1862e770 (patch) | |
tree | ab4443461c6e42b890802f2b5e13c184c7f69406 /rust/kernel/init.rs | |
parent | 071cedc84e907f6984b3de3285ec2b077d3c3cdb (diff) | |
download | linux-97de919d574e6a22f0d43a169b96274f1862e770.tar.xz |
rust: init: make guards in the init macros hygienic
Use hygienic identifiers for the guards instead of the field names. This
makes the init macros feel more like normal struct initializers, since
assigning identifiers with the name of a field does not create
conflicts.
Also change the internals of the guards, no need to make the `forget`
function `unsafe`, since users cannot access the guards anyways. Now the
guards are carried directly on the stack and have no extra `Cell<bool>`
field that marks if they have been forgotten or not, instead they are
just forgotten via `mem::forget`.
Suggested-by: Asahi Lina <lina@asahilina.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230814084602.25699-5-benno.lossin@proton.me
[ Cleaned a few trivial nits. ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/init.rs')
-rw-r--r-- | rust/kernel/init.rs | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs index d9a91950cba2..ecf6a4bd0ce4 100644 --- a/rust/kernel/init.rs +++ b/rust/kernel/init.rs @@ -206,7 +206,6 @@ use crate::{ use alloc::boxed::Box; use core::{ alloc::AllocError, - cell::Cell, convert::Infallible, marker::PhantomData, mem::MaybeUninit, |