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

Unsafe extern blocks #124482

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

spastorino
Copy link
Member

@spastorino spastorino commented Apr 28, 2024

This implements RFC 3484.

Tracking issue #123743 and RFC rust-lang/rfcs#3484

This is better reviewed commit by commit, the first 2 commits live also in a separate PR #124455.

This is a first working version that needs:

  • I need to review and tidy up commits
  • I need to extensively add tests and in particular tests about static items
  • Is based on Add new safety enum for inner extern items #124455, so we need to merge that one first.
  • Decision on the name missing_unsafe_on_extern attribute.
  • After the name is set I can prepare a PRs to stdarch crate and remove the commit on this PR that modifies the submodule to point to mine

@rustbot
Copy link
Collaborator

rustbot commented Apr 28, 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
Copy link
Collaborator

rustbot commented Apr 28, 2024

⚠️ Warning ⚠️

  • These commits modify submodules.

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 28, 2024
@rust-log-analyzer

This comment has been minimized.

@spastorino
Copy link
Member Author

⚠️ Warning ⚠️

* These commits modify **submodules**.

Ohh I forgot to mention this. I'd need to land some PRs, at least to stdarch so it doesn't warn for the usages of extern blocks without unsafe.
I was planning to do ![allow(unknown_lints)] + #![allow(missing_unsafe_on_extern)], so this doesn't warn in new versions and doesn't error in old versions for the usage of missing_unsafe_on_extern which is unknown.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 4, 2024

☔ The latest upstream changes (presumably #123602) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented May 4, 2024

The Miri subtree was changed

cc @rust-lang/miri

@bors
Copy link
Contributor

bors commented May 5, 2024

☔ The latest upstream changes (presumably #124631) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented May 5, 2024

☔ The latest upstream changes (presumably #124754) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented May 8, 2024

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling basic-toml v0.1.9
   Compiling askama_derive v0.12.5
    Checking askama v0.12.1
    Checking rustdoc v0.0.0 (/checkout/src/librustdoc)
error[E0063]: missing field `safety` in initializer of `DefKind`
     |
     |
1520 |                 "static" => Kind(DefKind::Static { mutability: Mutability::Not, nested: false }),
     |                                  ^^^^^^^^^^^^^^^ missing `safety`
For more information about this error, try `rustc --explain E0063`.
error: could not compile `rustdoc` (lib) due to 1 previous error
Build completed unsuccessfully in 0:02:15
  local time: Wed May  8 13:40:20 UTC 2024

@@ -342,6 +342,7 @@ fn jemalloc_magic() {
// linking, so we need to explicitly depend on the function.
#[cfg(target_os = "macos")]
{
#[allow(missing_unsafe_on_extern)]
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding an enormous amount of allow, what about keeping the lint allow-by-default until the bootstrap compiler has unsafe extern, so that then we can start using it in the codebase? That avoids having to change everything twice...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, totally. I guess that depends when do we want to land this change and then how much do we want to wait but yeah :).

Copy link
Member

Choose a reason for hiding this comment

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

On old editions I think the RFC says it should be allow-by-default for now anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohh good catch. I've implemented Felix's proposal rust-lang/rfcs#3484 (comment) which I see now is out of sync.
Going to fix this accordingly when I have some time.

@bors
Copy link
Contributor

bors commented May 9, 2024

☔ The latest upstream changes (presumably #124934) made this pull request unmergeable. Please resolve the merge conflicts.

@spastorino
Copy link
Member Author

This is waiting on a decision on #124455 or #125077 or any other preferred alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc O-windows Operating system: Windows PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc 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