Skip to content

unsafe: mutable-static: do not create reference #2736

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

Merged
merged 1 commit into from
May 6, 2025

Conversation

fw-immunant
Copy link
Collaborator

println! adds references (&) to its arguments, to avoid moving them.

This is undesirable here, because it is extremely error-prone to take references to static muts. We could println!("{}", {counter}), but this is somewhat exotic syntax and just sticking with dbg! also avoids this problem as it does not add references.

`println!` adds references (&) to its arguments, to avoid moving them.

This is undesirable here, because it is extremely error-prone to take
references to `static mut`s. We could `println!("{}", {counter})`, but
this is somewhat exotic syntax and just sticking with `dbg!` also
avoids this problem as it does not add references.
@fw-immunant fw-immunant merged commit 03df73e into main May 6, 2025
70 of 71 checks passed
@fw-immunant fw-immunant deleted the fw/mut-static-reference branch May 6, 2025 15:55
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