Repository navigation
remove redundant unsafe - #163918
Merged
Merged
remove redundant unsafe#163918
Conversation
Collaborator
|
cc @Amanieu, @folkertdev, @sayantn |
Collaborator
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
yilin0518
force-pushed
the
fix_arm_hint
branch
from
October 7, 2026 06:51
23daa0c to
75b0be8
Compare
JohnTitor
approved these changes
Oct 11, 2026
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Oct 11, 2026
remove redundant unsafe Related Zulipchat topic link: [Safety requirements of ARM hint APIs](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Safety.20requirements.20of.20ARM.20hint.20APIs/with/629609101) This PR tries to remove the unsafe in `core_arch/arm_shared/hint.rs`. As the Zulip topic discussed, these APIs have `#[cfg(any(...))]` attribute to restrict that these can only be compiled when specific architecture is met. So there seems no need to mark these APIs unsafe. For `__nop`, I found that in `riscv_shared` there exist the same `nop` instruction, but it is marked safe. The concrete path is `core_arch/src/riscv_shared/mod.rs` ```rust /// Generates the `NOP` instruction /// /// The NOP instruction does not change any architecturally visible state, except for /// advancing the `pc` and incrementing any applicable performance counters. #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn nop() { unsafe { asm!("nop", options(nomem, nostack, preserves_flags)); } } ``` But there is a remaining question: For `wfe` and `wfi`, they can be configurable to trap. So I think if needed, I can complement some discription about trap. Hoping you can give me some suggestion.
Contributor
|
⌛ Testing commit 75b0be8 with merge c833618... Workflow: https://github.com/rust-lang/rust/actions/runs/38145486415 |
Member
|
@bors yield |
Contributor
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #164159. |
rust-bors Bot
pushed a commit
that referenced
this pull request
Oct 11, 2026
Rollup merge of #163918 - yilin0518:fix_arm_hint, r=JohnTitor remove redundant unsafe Related Zulipchat topic link: [Safety requirements of ARM hint APIs](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Safety.20requirements.20of.20ARM.20hint.20APIs/with/629609101) This PR tries to remove the unsafe in `core_arch/arm_shared/hint.rs`. As the Zulip topic discussed, these APIs have `#[cfg(any(...))]` attribute to restrict that these can only be compiled when specific architecture is met. So there seems no need to mark these APIs unsafe. For `__nop`, I found that in `riscv_shared` there exist the same `nop` instruction, but it is marked safe. The concrete path is `core_arch/src/riscv_shared/mod.rs` ```rust /// Generates the `NOP` instruction /// /// The NOP instruction does not change any architecturally visible state, except for /// advancing the `pc` and incrementing any applicable performance counters. #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn nop() { unsafe { asm!("nop", options(nomem, nostack, preserves_flags)); } } ``` But there is a remaining question: For `wfe` and `wfi`, they can be configurable to trap. So I think if needed, I can complement some discription about trap. Hoping you can give me some suggestion.
github-actions Bot
pushed a commit
to rust-lang/stdarch
that referenced
this pull request
Oct 12, 2026
…uwer Rollup of 3 pull requests Successful merges: - rust-lang/rust#163918 (remove redundant unsafe) - rust-lang/rust#164047 (Remove indirection for `Expr` in `Body`) - rust-lang/rust#164154 (rustc-dev-guide subtree update)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Zulipchat topic link: Safety requirements of ARM hint APIs
This PR tries to remove the unsafe in
core_arch/arm_shared/hint.rs. As the Zulip topic discussed, these APIs have#[cfg(any(...))]attribute to restrict that these can only be compiled when specific architecture is met. So there seems no need to mark these APIs unsafe.For
__nop, I found that inriscv_sharedthere exist the samenopinstruction, but it is marked safe. The concrete path iscore_arch/src/riscv_shared/mod.rsBut there is a remaining question: For
wfeandwfi, they can be configurable to trap. So I think if needed, I can complement some discription about trap. Hoping you can give me some suggestion.