mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
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.