Skip to content

use &raw mut instead of casting &mut to raw pointer#197

Merged
nagisa merged 1 commit into
nagisa:masterfrom
hkBst:no-mut-ref-2-mut-static
Jul 4, 2026
Merged

use &raw mut instead of casting &mut to raw pointer#197
nagisa merged 1 commit into
nagisa:masterfrom
hkBst:no-mut-ref-2-mut-static

Conversation

@hkBst

@hkBst hkBst commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

This gets rid of:

warning: creating a mutable reference to mutable static
  --> src/test_helpers.rs:36:25
   |
36 |     TEST_STATIC_PTR == (&mut TEST_STATIC_PTR as *mut *mut _ as *mut _)
   |                         ^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
   |
   = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
   = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
   = note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
help: use `&raw mut` instead to create a raw pointer
   |
36 |     TEST_STATIC_PTR == (&raw mut TEST_STATIC_PTR as *mut *mut _ as *mut _)

@nagisa nagisa merged commit b3a1a4d into nagisa:master Jul 4, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants