rust: make `UnsafeCell` the outer type in `Opaque`
authorAlice Ryhl <aliceryhl@google.com>
Wed, 14 Jun 2023 11:53:28 +0000 (11:53 +0000)
committerMiguel Ojeda <ojeda@kernel.org>
Wed, 9 Aug 2023 23:18:34 +0000 (01:18 +0200)
commit35cad617df2eeef8440a38e82bb2d81ae32ca50d
treec242223c7b6afcd9846da86b59d6eeccfefbcda7
parent0bb1c9282e2cb38d199347d1d96b77f208b64810
rust: make `UnsafeCell` the outer type in `Opaque`

When combining `UnsafeCell` with `MaybeUninit`, it is idiomatic to use
`UnsafeCell` as the outer type. Intuitively, this is because a
`MaybeUninit<T>` might not contain a `T`, but we always want the effect
of the `UnsafeCell`, even if the inner value is uninitialized.

Now, strictly speaking, this doesn't really make a difference. The
compiler will always apply the `UnsafeCell` effect even if the inner
value is uninitialized. But I think we should follow the convention
here.

Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Link: https://lore.kernel.org/r/20230614115328.2825961-1-aliceryhl@google.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/types.rs