-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
static_mut_refs: Should the lint cover hidden references? #123060
Comments
@rustbot labels +I-lang-nominated What we need to discuss is whether, e.g., these cases should trigger an error in Rust 2024: // edition: 2024
static mut STATIC: &[u8; 3] = &[0, 1, 2];
fn main() { unsafe {
let _ = STATIC.len();
let _ = STATIC[0];
let _ = format!("{:?}", STATIC);
}} What was implemented in #117556 does not trigger an error for these. However, @scottmcm expressed a view that these should be included also:
|
I think that, if anything, the invisible ones are more important to lint(/break). At least if someone is doing |
I think it should cover hidden references, as expressed above. Triage was sparsely attended today, but maybe we can get team agreement async: |
Team member @scottmcm has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
+1 to this. I was quite confused when I saw that |
Agreed that this should cover hidden references. Not sure if we need an FCP to decide it, but @rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
@rustbot claim |
We reviewed this in the edition call today. We'll close this when we merge #124895. |
…haelwoerister Disallow hidden references to mutable static Closes rust-lang#123060 Tracking: - rust-lang#123758
…haelwoerister Disallow hidden references to mutable static Closes rust-lang#123060 Tracking: - rust-lang#123758
…haelwoerister Disallow hidden references to mutable static Closes rust-lang#123060 Tracking: - rust-lang#123758
…elwoerister Disallow hidden references to mutable static Closes rust-lang#123060 Tracking: - rust-lang#123758
…elwoerister Disallow hidden references to mutable static Closes rust-lang#123060 Tracking: - rust-lang#123758
…elwoerister,traviscross Disallow hidden references to mutable static Closes rust-lang#123060 Tracking: - rust-lang#123758
…ler-errors Disallow hidden references to mutable static Closes rust-lang#123060 Tracking: - rust-lang#123758
There is some discussion on #114447 (comment) about whether or not
static_mut_refs
should be triggering on code that takes references without using the&
sigil, such as method calls.This should probably be resolved soon if this is to be part of the edition. If this needs to change after the edition, the implementation will likely require separate code paths for the lint versus edition behavior, which could become confusing, or risk unintentional breakage.
The text was updated successfully, but these errors were encountered: