Three warnings flag forward-compatibility / dependency migration work.
1. static_mut_refs (2 sites)
Both create a shared reference to a mutable static. In Rust 2024 this becomes a hard error.
warning: creating a shared reference to mutable static
--> crates/perry-runtime/src/object.rs:796:22
|
796 | for entry in TRANSITION_CACHE_GLOBAL.iter() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
warning: creating a shared reference to mutable static
--> crates/perry-runtime/src/string.rs:2828:22
|
2828 | for entry in INTERN_TABLE.iter() {
| ^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
Fix options:
a) Wrap the static in OnceCell / Mutex / RwLock — correct, but adds locking on hot paths (transition cache, string intern).
b) Use &raw const to obtain a raw pointer and iterate via unsafe — preserves performance, makes the unsafety explicit.
The right call depends on whether either path needs concurrent access; both currently look thread-local. Recommend option (b) unless a thread-safety audit shows otherwise.
2. Deprecated libc::mach_host_self (1 site)
warning: use of deprecated function `libc::mach_host_self`: Use the `mach2` crate instead
Requires adding the mach2 dependency and updating the call site.
Why grouped
All three are "prepare for Rust 2024 / current deprecations". Same reviewer mental model. If the mach2 migration adds non-trivial API surface or new dependency tree, split into 3a (static_mut_refs) and 3b (mach2 migration).
Context
Carved out of the warning-cleanup PR (chore: reduce compile warnings 325 → 125).
Three warnings flag forward-compatibility / dependency migration work.
1.
static_mut_refs(2 sites)Both create a shared reference to a mutable static. In Rust 2024 this becomes a hard error.
Fix options:
a) Wrap the static in
OnceCell/Mutex/RwLock— correct, but adds locking on hot paths (transition cache, string intern).b) Use
&raw constto obtain a raw pointer and iterate viaunsafe— preserves performance, makes the unsafety explicit.The right call depends on whether either path needs concurrent access; both currently look thread-local. Recommend option (b) unless a thread-safety audit shows otherwise.
2. Deprecated
libc::mach_host_self(1 site)Requires adding the
mach2dependency and updating the call site.Why grouped
All three are "prepare for Rust 2024 / current deprecations". Same reviewer mental model. If the
mach2migration adds non-trivial API surface or new dependency tree, split into 3a (static_mut_refs) and 3b (mach2migration).Context
Carved out of the warning-cleanup PR (
chore: reduce compile warnings 325 → 125).