Skip to content

Don't allow unsafe statics outside of extern blocks #127943

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 18, 2024

This PR fixes a regression where we allowed unsafe static items in top-level modules (i.e. outside of unsafe extern blocks).

It's harder IMO to integrate this into the check_item_safety function, so I opted to just put this check on the static item itself.

Beta version of this lives at #127944.

r? @oli-obk or @spastorino

@rustbot
Copy link
Collaborator

rustbot commented Jul 18, 2024

Could not assign reviewer from: oli-obk.
User(s) oli-obk are either the PR author, already assigned, or on vacation, and there are no other candidates.
Use r? to specify someone else to assign.

@compiler-errors compiler-errors added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jul 18, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jul 18, 2024

r? @michaelwoerister

rustbot has assigned @michaelwoerister.
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 Jul 18, 2024
@compiler-errors compiler-errors removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jul 18, 2024
@spastorino
Copy link
Member

The PR is fine to me, feel free to r=me but ... can't we make check_item_safety receive item/item_kind and have the check inside of the function so we stick with checking safety always there?.
Anyway ... as I've said ... feel free to r=me and I can take a look at some point and see if doing what I'm saying would be better or not.

@compiler-errors
Copy link
Member Author

@bors r=spastorino rollup

@bors
Copy link
Collaborator

bors commented Jul 19, 2024

📌 Commit 2f5a84e has been approved by spastorino

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 19, 2024

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@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 Jul 19, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 19, 2024
…orino

Don't allow unsafe statics outside of extern blocks

This PR fixes a regression where we allowed `unsafe static` items in top-level modules (i.e. outside of `unsafe extern` blocks).

It's harder IMO to integrate this into the `check_item_safety` function, so I opted to just put this check on the `static` item itself.

Beta version of this lives at rust-lang#127944.

r? `@oli-obk` or `@spastorino`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 19, 2024
…rk-Simulacrum

Don't allow unsafe statics outside of extern blocks (beta version)

This PR fixes a regression where we allowed `unsafe static` items in top-level modules (i.e. outside of `unsafe extern` blocks).

rust-lang#127943 does not rebase cleanly, so I've prepared an extremely pared down version of this PR for beta purposes.
tgross35 added a commit to tgross35/rust that referenced this pull request Jul 19, 2024
…orino

Don't allow unsafe statics outside of extern blocks

This PR fixes a regression where we allowed `unsafe static` items in top-level modules (i.e. outside of `unsafe extern` blocks).

It's harder IMO to integrate this into the `check_item_safety` function, so I opted to just put this check on the `static` item itself.

Beta version of this lives at rust-lang#127944.

r? ``@oli-obk`` or ``@spastorino``
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 19, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#123196 (Add Process support for UEFI)
 - rust-lang#127350 (Parser: Suggest Placing the Return Type After Function Parameters)
 - rust-lang#127523 (Migrate `dump-ice-to-disk` and `panic-abort-eh_frame` `run-make` tests to rmake)
 - rust-lang#127662 (When finding item gated behind a `cfg` flag, point at it)
 - rust-lang#127903 (`force_collect` improvements)
 - rust-lang#127932 (rustdoc: fix `current` class on sidebar modnav)
 - rust-lang#127943 (Don't allow unsafe statics outside of extern blocks)

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

Rollup of 6 pull requests

Successful merges:

 - rust-lang#127350 (Parser: Suggest Placing the Return Type After Function Parameters)
 - rust-lang#127621 (Rewrite and rename `issue-22131` and `issue-26006` `run-make` tests to rmake)
 - rust-lang#127662 (When finding item gated behind a `cfg` flag, point at it)
 - rust-lang#127903 (`force_collect` improvements)
 - rust-lang#127932 (rustdoc: fix `current` class on sidebar modnav)
 - rust-lang#127943 (Don't allow unsafe statics outside of extern blocks)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6fe68f8 into rust-lang:master Jul 19, 2024
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 19, 2024
Rollup merge of rust-lang#127943 - compiler-errors:no-unsafe, r=spastorino

Don't allow unsafe statics outside of extern blocks

This PR fixes a regression where we allowed `unsafe static` items in top-level modules (i.e. outside of `unsafe extern` blocks).

It's harder IMO to integrate this into the `check_item_safety` function, so I opted to just put this check on the `static` item itself.

Beta version of this lives at rust-lang#127944.

r? ```@oli-obk``` or ```@spastorino```
@rustbot rustbot added this to the 1.81.0 milestone Jul 19, 2024
@Mark-Simulacrum Mark-Simulacrum added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jul 20, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. 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.

6 participants