Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registries: no need for static mut or unsafe + use std's LazyLock #663

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

cormacrelf
Copy link
Contributor

This fixes nightly rustc yelling about:

error: creating a shared reference to mutable static is discouraged
  --> src/user_input/trait_serde.rs:69:37
   |
69 |         let mut registry = unsafe { AXISLIKE_REGISTRY.write().unwrap() };
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

And drops a dependency.

Ref #662 which had build failures.

This fixes nightly rustc yelling about:

    error: creating a shared reference to mutable static is discouraged
      --> src/user_input/trait_serde.rs:69:37
       |
    69 |         let mut registry = unsafe { AXISLIKE_REGISTRY.write().unwrap() };
       |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
       |
       = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
       = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

And drops a dependency.
@alice-i-cecile alice-i-cecile added the code-quality Make the code faster or prettier label Dec 6, 2024
Copy link
Contributor

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very pleased to have that gone. Thank you!

@alice-i-cecile alice-i-cecile enabled auto-merge (squash) December 6, 2024 00:41
auto-merge was automatically disabled December 6, 2024 01:01

Head branch was pushed to by a user without write access

@alice-i-cecile alice-i-cecile enabled auto-merge (squash) December 6, 2024 01:17
@alice-i-cecile alice-i-cecile merged commit 37dc091 into Leafwing-Studios:main Dec 6, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality Make the code faster or prettier
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants