Skip to content

Conversation

ojeda
Copy link
Member

@ojeda ojeda commented Mar 31, 2025

Similar to what was done for Zeroable<NonNull<T>> in commit 9caa350 ("last docs changes and zeroable unsized pointer fixes"), the latest Rust documentation [1] says it guarantees that transmute::<_, Option<T>>([0u8; size_of::<T>()]) is sound and produces Option::<T>::None only in some cases. In particular, it says:

`Box<U>` (specifically, only `Box<U, Global>`) when `U: Sized`

Thus restrict the impl to Sized, and use similar wording as in that commit too.

Link: https://doc.rust-lang.org/stable/std/option/index.html#representation [1]

@ojeda
Copy link
Member Author

ojeda commented Mar 31, 2025

For the kernel side, if you decide to send it as a fix, then the fix tag would be:

Fixes: 9b2299af3b92 ("rust: pin-init: add `std` and `alloc` support from the user-space version")

@ojeda ojeda force-pushed the zeroable-option-box-fix branch from 9314dca to b41aad0 Compare March 31, 2025 21:06
Similar to what was done for `Zeroable<NonNull<T>>` in commit 9caa350
("last docs changes and zeroable unsized pointer fixes"), the latest Rust
documentation [1] says it guarantees that `transmute::<_, Option<T>>([0u8;
size_of::<T>()])` is sound and produces `Option::<T>::None` only in some
cases. In particular, it says:

    `Box<U>` (specifically, only `Box<U, Global>`) when `U: Sized`

Thus restrict the `impl` to `Sized`, and use similar wording as in that
commit too.

Link: https://doc.rust-lang.org/stable/std/option/index.html#representation [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
@ojeda ojeda force-pushed the zeroable-option-box-fix branch from b41aad0 to a6007cf Compare April 1, 2025 16:34
It allows, for instance, kitty to pick it up as links properly [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Copy link
Member

@BennoLossin BennoLossin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes!

@BennoLossin BennoLossin merged commit fdc7061 into Rust-for-Linux:main Apr 1, 2025
26 checks passed
@ojeda ojeda deleted the zeroable-option-box-fix branch April 1, 2025 22:19
BennoLossin pushed a commit to BennoLossin/linux that referenced this pull request Apr 2, 2025
It allows, for instance, kitty to pick it up as links properly [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
[ Change case in title. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
BennoLossin pushed a commit to BennoLossin/linux that referenced this pull request Apr 2, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
BennoLossin pushed a commit to BennoLossin/linux that referenced this pull request Apr 7, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
Fixes: 84837cf ("rust: pin-init: change examples to the user-space version")
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
BennoLossin pushed a commit to BennoLossin/linux that referenced this pull request Apr 7, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
Fixes: 84837cf ("rust: pin-init: change examples to the user-space version")
Cc: stable@vger.kernel.org
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request Apr 7, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
Fixes: 84837cf ("rust: pin-init: change examples to the user-space version")
Cc: stable@vger.kernel.org
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
ojeda added a commit to ojeda/linux that referenced this pull request Apr 8, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
Fixes: 84837cf ("rust: pin-init: change examples to the user-space version")
Cc: stable@vger.kernel.org
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20250407201755.649153-3-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
ojeda added a commit to Rust-for-Linux/linux that referenced this pull request Apr 8, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
Fixes: 84837cf ("rust: pin-init: change examples to the user-space version")
Cc: stable@vger.kernel.org
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20250407201755.649153-3-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
BennoLossin pushed a commit to BennoLossin/linux that referenced this pull request Apr 14, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
Fixes: 84837cf ("rust: pin-init: change examples to the user-space version")
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
gShahr pushed a commit to gShahr/linux that referenced this pull request Apr 21, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
Fixes: 84837cf ("rust: pin-init: change examples to the user-space version")
Cc: stable@vger.kernel.org
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20250407201755.649153-3-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
gShahr pushed a commit to gShahr/linux that referenced this pull request Apr 22, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
Fixes: 84837cf ("rust: pin-init: change examples to the user-space version")
Cc: stable@vger.kernel.org
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20250407201755.649153-3-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
gShahr pushed a commit to gShahr/linux that referenced this pull request Apr 24, 2025
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst

Thus use Markdown autolinks for a couple links that were missing it.

It also helps to get proper linking in some software like kitty [1].

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: Rust-for-Linux/pin-init#32 (comment) [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: Rust-for-Linux/pin-init@dd230d6
Fixes: 84837cf ("rust: pin-init: change examples to the user-space version")
Cc: stable@vger.kernel.org
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20250407201755.649153-3-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants