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 entry #4418

Conversation

brooksprumo
Copy link

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 entry:

warning: creating a shared reference to mutable static is discouraged
  --> entry/src/entry.rs:83:14
   |
83 |     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
alexpyattaev
alexpyattaev previously approved these changes Jan 13, 2025
Copy link

@alexpyattaev alexpyattaev left a comment

Choose a reason for hiding this comment

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

Lgtm

@brooksprumo brooksprumo requested a review from bw-solana January 13, 2025 14:55
@brooksprumo
Copy link
Author

@bw-solana Can I get your review here as well, please? I want to make sure I haven't missed anything. Feel free to tag in others to review as well.

bw-solana
bw-solana previously approved these changes Jan 13, 2025
Copy link

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

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

LGTM! Left one minor suggestion

@@ -51,23 +51,22 @@ fn init(name: &OsStr) {
static INIT_HOOK: Once = Once::new();

info!("Loading {:?}", name);
unsafe {

Choose a reason for hiding this comment

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

🎉

entry/src/entry.rs Show resolved Hide resolved
@brooksprumo brooksprumo dismissed stale reviews from bw-solana and alexpyattaev via 4952a37 January 13, 2025 15:50
@brooksprumo brooksprumo requested a review from bw-solana January 13, 2025 15:50
Copy link

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

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

LGTM

@brooksprumo brooksprumo merged commit f1a2143 into anza-xyz:master Jan 13, 2025
47 checks passed
@brooksprumo brooksprumo deleted the rust-1.84.0/clippy/static-mut-refs/entry branch January 13, 2025 18:15
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
3 participants