From b7d5cadc8d8b1e940d1e7bdebd753c0a07c42fa7 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Fri, 22 May 2026 20:13:18 +0200 Subject: [PATCH 1/2] fix(d_net): silence static_mut_refs on EXITMSG buffer `EXITMSG.len()` inside `PlayerQuitGame` implicitly created a shared reference to the function-local `static mut EXITMSG` to read its length, tripping the Rust 2024 `static_mut_refs` warning. Hoist the length into a local `const EXITMSG_LEN: usize = 80` used for both the array type and the `M_StringCopy` size argument, so no reference to the static is created. --- room/src/doom/d_net.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/room/src/doom/d_net.rs b/room/src/doom/d_net.rs index 112e70b..8e8cb42 100644 --- a/room/src/doom/d_net.rs +++ b/room/src/doom/d_net.rs @@ -294,12 +294,13 @@ extern "C" { unsafe fn PlayerQuitGame(player_idx: usize) { /// 80-byte scratch buffer holding the formatted "Player N left the game" /// message; its address is passed to the console-player's message pointer. - static mut EXITMSG: [c_char; 80] = [0; 80]; + const EXITMSG_LEN: usize = 80; + static mut EXITMSG: [c_char; EXITMSG_LEN] = [0; EXITMSG_LEN]; M_StringCopy( std::ptr::addr_of_mut!(EXITMSG[0]), DEH_String(EXIT_MSG.as_ptr() as *const c_char), - EXITMSG.len(), + EXITMSG_LEN, ); EXITMSG[7] += player_idx as c_char; From 6d324f06cdeed83698db2cc2337c379db1bdc51c Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Fri, 22 May 2026 20:20:18 +0200 Subject: [PATCH 2/2] docs(d_net): move EXITMSG buffer doc back onto the buffer After the previous commit hoisted the buffer capacity into `EXITMSG_LEN`, the existing doc comment attached to the new `const` instead of the `static mut EXITMSG` it describes. Move the buffer doc onto `EXITMSG` and add a short doc for `EXITMSG_LEN` explaining why it exists. --- room/src/doom/d_net.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/room/src/doom/d_net.rs b/room/src/doom/d_net.rs index 8e8cb42..39eddc2 100644 --- a/room/src/doom/d_net.rs +++ b/room/src/doom/d_net.rs @@ -292,9 +292,12 @@ extern "C" { /// Caller must ensure `player_idx < MAXPLAYERS` and that the global state /// (`players`, `playeringame`, `consoleplayer`, `demorecording`) is valid. unsafe fn PlayerQuitGame(player_idx: usize) { + /// Capacity of [`EXITMSG`], named so `M_StringCopy` does not have to take + /// a shared reference to the `static mut` to read its length. + const EXITMSG_LEN: usize = 80; + /// 80-byte scratch buffer holding the formatted "Player N left the game" /// message; its address is passed to the console-player's message pointer. - const EXITMSG_LEN: usize = 80; static mut EXITMSG: [c_char; EXITMSG_LEN] = [0; EXITMSG_LEN]; M_StringCopy(