Skip to content

Commit 76be6bb

Browse files
authored
Rollup merge of #81530 - ojeda:sys-use-abort-instead-of-wasm32-unreachable, r=Mark-Simulacrum
sys: use `process::abort()` instead of `arch::wasm32::unreachable()` Rationale: - `abort()` lowers to `wasm32::unreachable()` anyway. - `abort()` isn't `unsafe`. - `abort()` matches the comment better. - `abort()` avoids confusion by future readers (e.g. #81527): the naming of wasm's `unreachable` instruction is a bit unfortunate because it is not related to the `unreachable()` intrinsic (intended to trigger UB). Codegen is likely to be different since `unreachable()` is `inline` while `abort()` is `cold`. Since it doesn't look like we are expecting here to trigger this case, the latter seems better anyway.
2 parents 71792d8 + c7f4154 commit 76be6bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/std/src/sys/wasm/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub fn my_id() -> u32 {
8686
if MY_ID == 0 {
8787
let mut cur = NEXT_ID.load(SeqCst);
8888
MY_ID = loop {
89-
let next = cur.checked_add(1).unwrap_or_else(|| crate::arch::wasm32::unreachable());
89+
let next = cur.checked_add(1).unwrap_or_else(|| crate::process::abort());
9090
match NEXT_ID.compare_exchange(cur, next, SeqCst, SeqCst) {
9191
Ok(_) => break next,
9292
Err(i) => cur = i,

0 commit comments

Comments
 (0)