Skip to content

Clarify that safe extern items do not require unsafe #1970

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 5 commits into from
Aug 19, 2025

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Aug 19, 2025

This clarifies items.extern.fn-safety that it only applies to unsafe items. safe items do not require an unsafe context.

I think this was just missed in #1536.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 19, 2025
ehuss and others added 5 commits August 19, 2025 21:20
This clarifies items.extern.fn-safety that it only applies to unsafe
items. `safe` items do not require an unsafe context.

I think this was just missed in rust-lang#1536.
This rule applies to both fn and static, so remove the "fn" part of the
rule name.
In light of `unsafe extern`, we need to note that only unsafe extern
statics need `unsafe { .. }` and to clarify that not all foreign
functions are necessarily unsafe to call.

Co-authored-by: ehuss
In light of `unsafe extern`, we need to note that this is another
position that `unsafe` is allowed.  While we're here, let's make some
further revisions to clean up the start of this chapter, including
separating off into a rule these allowed positions.

Co-authored-by: ehuss
@traviscross traviscross force-pushed the extern-block-unsafe-fn-call branch from 07a109a to 3b88b41 Compare August 19, 2025 21:26
@traviscross traviscross added this pull request to the merge queue Aug 19, 2025
Merged via the queue into rust-lang:master with commit 82c9863 Aug 19, 2025
5 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 19, 2025
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.

3 participants