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

Only allow immutable statics with #[linkage] #125046

Merged
merged 1 commit into from
May 27, 2024

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented May 12, 2024

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented May 12, 2024

r? @cjgillot

rustbot has assigned @cjgillot.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 12, 2024
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the no_mutable_static_linkage branch from e4a404a to 88b27eb Compare May 12, 2024 15:25
@@ -327,6 +327,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
} else {
codegen_fn_attrs.linkage = linkage;
}
if tcx.is_mutable_static(did.into()) {
tcx.dcx()
.span_err(attr.span, "mutable statics are not allowed with #[linkage]");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.span_err(attr.span, "mutable statics are not allowed with #[linkage]");
.span_err(attr.span, "mutable statics are not allowed with `#[linkage]`");

Also maybe worth while explaining why in a note, or linking to something that explains why.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@bjorn3 bjorn3 force-pushed the no_mutable_static_linkage branch from 88b27eb to 715d72f Compare May 13, 2024 13:41
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the no_mutable_static_linkage branch from 715d72f to 531dae1 Compare May 13, 2024 14:34
@bjorn3
Copy link
Member Author

bjorn3 commented May 19, 2024

@rustbot ready

@cjgillot
Copy link
Contributor

Should this be considered as a breaking change that requires t-lang signoff, or as something that has never worked ever?

@bjorn3
Copy link
Member Author

bjorn3 commented May 19, 2024

#[linkage] is an unstable feature. It seems like an oversight to me that static mut was not denied when used with #[linkage].

@cjgillot
Copy link
Contributor

Indeed.
@bors r+

@bors
Copy link
Contributor

bors commented May 26, 2024

📌 Commit 531dae1 has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 26, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request May 26, 2024
…r=cjgillot

Only allow immutable statics with #[linkage]
bors added a commit to rust-lang-ci/rust that referenced this pull request May 26, 2024
…kingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#125046 (Only allow immutable statics with #[linkage])
 - rust-lang#125466 (Don't continue probing for method if in suggestion and autoderef hits ambiguity)
 - rust-lang#125469 (Don't skip out of inner const when looking for body for suggestion)
 - rust-lang#125530 (cleanup dependence of `ExtCtxt` in transcribe when macro expansion)
 - rust-lang#125535 (clean-up: remove deprecated field `dist.missing-tools`)
 - rust-lang#125539 (crashes: increment the number of tracked ones)
 - rust-lang#125544 (Also mention my-self for other check-cfg docs changes)
 - rust-lang#125559 (Simplify the `unchecked_sh[lr]` ub-checks a bit)
 - rust-lang#125566 (Notify T-rustdoc for beta-accepted and stable-accepted too)
 - rust-lang#125582 (Avoid a `FieldIdx::from_usize` in InstSimplify)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request May 26, 2024
…kingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#125046 (Only allow immutable statics with #[linkage])
 - rust-lang#125466 (Don't continue probing for method if in suggestion and autoderef hits ambiguity)
 - rust-lang#125469 (Don't skip out of inner const when looking for body for suggestion)
 - rust-lang#125530 (cleanup dependence of `ExtCtxt` in transcribe when macro expansion)
 - rust-lang#125535 (clean-up: remove deprecated field `dist.missing-tools`)
 - rust-lang#125539 (crashes: increment the number of tracked ones)
 - rust-lang#125544 (Also mention my-self for other check-cfg docs changes)
 - rust-lang#125559 (Simplify the `unchecked_sh[lr]` ub-checks a bit)
 - rust-lang#125566 (Notify T-rustdoc for beta-accepted and stable-accepted too)
 - rust-lang#125582 (Avoid a `FieldIdx::from_usize` in InstSimplify)

r? `@ghost`
`@rustbot` modify labels: rollup
jhpratt added a commit to jhpratt/rust that referenced this pull request May 26, 2024
…r=cjgillot

Only allow immutable statics with #[linkage]
jhpratt added a commit to jhpratt/rust that referenced this pull request May 26, 2024
…r=cjgillot

Only allow immutable statics with #[linkage]
bors added a commit to rust-lang-ci/rust that referenced this pull request May 27, 2024
…kingjubilee

Rollup of 8 pull requests

Successful merges:

 - rust-lang#124048 (Support C23's Variadics Without a Named Parameter)
 - rust-lang#125046 (Only allow immutable statics with #[linkage])
 - rust-lang#125466 (Don't continue probing for method if in suggestion and autoderef hits ambiguity)
 - rust-lang#125469 (Don't skip out of inner const when looking for body for suggestion)
 - rust-lang#125544 (Also mention my-self for other check-cfg docs changes)
 - rust-lang#125559 (Simplify the `unchecked_sh[lr]` ub-checks a bit)
 - rust-lang#125566 (Notify T-rustdoc for beta-accepted and stable-accepted too)
 - rust-lang#125582 (Avoid a `FieldIdx::from_usize` in InstSimplify)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5860d43 into rust-lang:master May 27, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 27, 2024
Rollup merge of rust-lang#125046 - bjorn3:no_mutable_static_linkage, r=cjgillot

Only allow immutable statics with #[linkage]
@bjorn3 bjorn3 deleted the no_mutable_static_linkage branch May 27, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants