forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use &raw [mut] place
instead of addr_of[_mut]!(place)
#1148
Labels
good first issue
Good for newcomers
• lib
Related to the `rust/` library.
medium
Expected to be an issue of medium difficulty to resolve.
Comments
I'd like to take this one one on |
intel-lab-lkp
pushed a commit
to intel-lab-lkp/linux
that referenced
this issue
Mar 13, 2025
Since Rust 1.82.0 the `raw_ref_op` feature is stable. By enabling this feature we can use `&raw place` and `&raw mut place` instead of using `addr_of!(place)` and `addr_of_mut!(place)` macros. This will allow us to reduce macro complexity, and improve consistency with existing reference syntax as `&raw`, `&raw mut` is very similar to `&`, `&mut` making it fit more naturally with other existing code. Suggested-by: Benno Lossin <[email protected]> Link: Rust-for-Linux#1148 Signed-off-by: Antonio Hickey <[email protected]>
intel-lab-lkp
pushed a commit
to intel-lab-lkp/linux
that referenced
this issue
Mar 13, 2025
With the `raw_ref_op` feature enabled we no longer want to allow use of `addr_of!` and `addr_of_mut!` macros. We instead want to use `&raw` and `&raw mut` to get raw pointers to a place. Suggested-by: Benno Lossin <[email protected]> Link: Rust-for-Linux#1148 Signed-off-by: Antonio Hickey <[email protected]>
intel-lab-lkp
pushed a commit
to intel-lab-lkp/linux
that referenced
this issue
Mar 13, 2025
Replacing all occurrences of `addr_of!(place)` with `&raw place`, and all occurrences of `addr_of_mut!(place)` with `&raw mut place`. Utilizing the new feature will allow us to reduce macro complexity, and improve consistency with existing reference syntax as `&raw`, `&raw mut` is very similar to `&`, `&mut` making it fit more naturally with other existing code. Depends on: Patch 1/3 0001-rust-enable-raw_ref_op-feature.patch Suggested-by: Benno Lossin <[email protected]> Link: Rust-for-Linux#1148 Signed-off-by: Antonio Hickey <[email protected]>
ojeda
pushed a commit
that referenced
this issue
Mar 23, 2025
Since Rust 1.82.0 the `raw_ref_op` feature is stable [1]. By enabling this feature we can use `&raw const place` and `&raw mut place` instead of using `addr_of!(place)` and `addr_of_mut!(place)` macros. Allowing us to reduce macro complexity, and improve consistency with existing reference syntax as `&raw const`, `&raw mut` are similar to `&`, `&mut` making it fit more naturally with other existing code. Suggested-by: Benno Lossin <[email protected]> Link: #1148 Link: https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#native-syntax-for-creating-a-raw-pointer [1] Signed-off-by: Antonio Hickey <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Reviewed-by: Tamir Duberstein <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Removed dashed line change as discussed. Added Link to the explanation of the feature in the Rust 1.82.0 release blog post. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
ojeda
pushed a commit
that referenced
this issue
Mar 23, 2025
Replace all occurrences (one) of `addr_of_mut!(place)` with `&raw mut place`. This will allow us to reduce macro complexity, and improve consistency with existing reference syntax as `&raw mut` is similar to `&mut` making it fit more naturally with other existing code. Suggested-by: Benno Lossin <[email protected]> Link: #1148 Signed-off-by: Antonio Hickey <[email protected]> Acked-by: Andreas Hindborg <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
good first issue
Good for newcomers
• lib
Related to the `rust/` library.
medium
Expected to be an issue of medium difficulty to resolve.
Since Rust 1.82.0, the
raw_ref_op
feature is stable. This means that in order to get a raw pointer to a place, one can write&raw place
instead of having to useaddr_of!(place)
.A patch series addressing this issue should:
addr_of[_mut]!
macros to use the raw ref operators instead.raw_ref_op
feature. The reason for this is that the kernel currently has a minimum Rust version of 1.78.0. So older compilers will need to have it enabled. Since it already is stable in a newer version this is OK.disallowed-macros
list in.clippy.toml
to prevent further introductions of that macro.This requires submitting a proper patch to the LKML and the Rust for Linux mailing list. Please recall to test your changes (including generating the documentation if changed, running the Rust doctests if changed, etc.), to use a proper title for the commit, to sign your commit under the Developer's Certificate of Origin and to add a
Suggested-by:
tag and aLink:
tag to this issue. Please see https://docs.kernel.org/process/submitting-patches.html and https://rust-for-linux.com/contributing for details.Please take this issue only if you are new to the kernel development process and you would like to use it as a test to submit your first patch to the kernel. Please do not take it if you do not plan to make other contributions to the kernel.
The text was updated successfully, but these errors were encountered: