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

Replaces static mutable references in perf_libs #4417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brooksprumo
Copy link

@brooksprumo brooksprumo commented Jan 12, 2025

Problem

New clippy lints when upgrading to rust 1.84.0.

Some are related to creating references to mutable statics. Here's the new lint for perf::perf_libs:

warning: creating a shared reference to mutable static is discouraged
   --> perf/src/perf_libs.rs:187:14
    |
187 |     unsafe { API.as_ref() }
    |              ^^^^^^^^^^^^ 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
    = note: `#[warn(static_mut_refs)]` on by default

Summary of Changes

Replace Once with OnceLock for the API, as it is the preferred way to do Once+data.

Partially fixes #4380

@brooksprumo brooksprumo self-assigned this Jan 12, 2025
@brooksprumo brooksprumo marked this pull request as ready for review January 13, 2025 01:32
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.

New clippy lints in Rust 1.84.0
1 participant