-
Notifications
You must be signed in to change notification settings - Fork 544
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
traviscross
merged 5 commits into
rust-lang:master
from
ehuss:extern-block-unsafe-fn-call
Aug 19, 2025
Merged
Clarify that safe extern items do not require unsafe #1970
traviscross
merged 5 commits into
rust-lang:master
from
ehuss:extern-block-unsafe-fn-call
Aug 19, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
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
07a109a
to
3b88b41
Compare
traviscross
approved these changes
Aug 19, 2025
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Aug 25, 2025
Update books ## rust-lang/nomicon 1 commits in 3ff384320598bbe8d8cfe5cb8f18f78a3a3e6b15..57ed4473660565d9357fcae176b358d7e8724ebf 2025-08-18 17:31:07 UTC to 2025-08-18 17:31:07 UTC - Fix unknown field `author` error when building the book (rust-lang/nomicon#500) ## rust-lang/reference 11 commits in 59b8af811886313577615c2cf0e045f01faed88b..89f67b3c1b904cbcd9ed55e443d6fc67c8ca2769 2025-08-22 07:16:52 UTC to 2025-08-14 18:42:19 UTC - Update `instruction_set` to use the attribute template (rust-lang/reference#1912) - Update `debugger_visualizer` to use the attribute template (rust-lang/reference#1922) - Update `collapse_debuginfo` to use the attribute template (rust-lang/reference#1923) - Clarify operand evaluation order in compound assignment with primitiv… (rust-lang/reference#1941) - Switch to using native mdbook fragment redirects (rust-lang/reference#1965) - Fix traits implemented for function items (rust-lang/reference#1969) - Clarify that safe extern items do not require unsafe (rust-lang/reference#1970) - Update `type_length_limit` to use the attribute template (rust-lang/reference#1917) - Add missing rule identifier for const outer generics (rust-lang/reference#1962) - Fix indentation of static path restriction text (rust-lang/reference#1961) - Add doc for `sse4a` and `tbm` (rust-lang/reference#1949) ## rust-lang/rust-by-example 2 commits in adc1f3b9012ad3255eea2054ca30596a953d053d..ad27f82c18464525c761a4a8db2e01785da59e1f 2025-08-20 23:50:16 UTC to 2025-08-13 21:41:46 UTC - Support building books using mdbook in main (v0.5.x) (rust-lang/rust-by-example#1952) - Improve the hints in `fmt` (1.2.3. Formatting); mention type casting (rust-lang/rust-by-example#1951)
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Aug 26, 2025
Update books ## rust-lang/nomicon 1 commits in 3ff384320598bbe8d8cfe5cb8f18f78a3a3e6b15..57ed4473660565d9357fcae176b358d7e8724ebf 2025-08-18 17:31:07 UTC to 2025-08-18 17:31:07 UTC - Fix unknown field `author` error when building the book (rust-lang/nomicon#500) ## rust-lang/reference 11 commits in 59b8af811886313577615c2cf0e045f01faed88b..89f67b3c1b904cbcd9ed55e443d6fc67c8ca2769 2025-08-22 07:16:52 UTC to 2025-08-14 18:42:19 UTC - Update `instruction_set` to use the attribute template (rust-lang/reference#1912) - Update `debugger_visualizer` to use the attribute template (rust-lang/reference#1922) - Update `collapse_debuginfo` to use the attribute template (rust-lang/reference#1923) - Clarify operand evaluation order in compound assignment with primitiv… (rust-lang/reference#1941) - Switch to using native mdbook fragment redirects (rust-lang/reference#1965) - Fix traits implemented for function items (rust-lang/reference#1969) - Clarify that safe extern items do not require unsafe (rust-lang/reference#1970) - Update `type_length_limit` to use the attribute template (rust-lang/reference#1917) - Add missing rule identifier for const outer generics (rust-lang/reference#1962) - Fix indentation of static path restriction text (rust-lang/reference#1961) - Add doc for `sse4a` and `tbm` (rust-lang/reference#1949) ## rust-lang/rust-by-example 2 commits in adc1f3b9012ad3255eea2054ca30596a953d053d..ad27f82c18464525c761a4a8db2e01785da59e1f 2025-08-20 23:50:16 UTC to 2025-08-13 21:41:46 UTC - Support building books using mdbook in main (v0.5.x) (rust-lang/rust-by-example#1952) - Improve the hints in `fmt` (1.2.3. Formatting); mention type casting (rust-lang/rust-by-example#1951)
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Aug 26, 2025
Update books ## rust-lang/nomicon 1 commits in 3ff384320598bbe8d8cfe5cb8f18f78a3a3e6b15..57ed4473660565d9357fcae176b358d7e8724ebf 2025-08-18 17:31:07 UTC to 2025-08-18 17:31:07 UTC - Fix unknown field `author` error when building the book (rust-lang/nomicon#500) ## rust-lang/reference 11 commits in 59b8af811886313577615c2cf0e045f01faed88b..89f67b3c1b904cbcd9ed55e443d6fc67c8ca2769 2025-08-22 07:16:52 UTC to 2025-08-14 18:42:19 UTC - Update `instruction_set` to use the attribute template (rust-lang/reference#1912) - Update `debugger_visualizer` to use the attribute template (rust-lang/reference#1922) - Update `collapse_debuginfo` to use the attribute template (rust-lang/reference#1923) - Clarify operand evaluation order in compound assignment with primitiv… (rust-lang/reference#1941) - Switch to using native mdbook fragment redirects (rust-lang/reference#1965) - Fix traits implemented for function items (rust-lang/reference#1969) - Clarify that safe extern items do not require unsafe (rust-lang/reference#1970) - Update `type_length_limit` to use the attribute template (rust-lang/reference#1917) - Add missing rule identifier for const outer generics (rust-lang/reference#1962) - Fix indentation of static path restriction text (rust-lang/reference#1961) - Add doc for `sse4a` and `tbm` (rust-lang/reference#1949) ## rust-lang/rust-by-example 2 commits in adc1f3b9012ad3255eea2054ca30596a953d053d..ad27f82c18464525c761a4a8db2e01785da59e1f 2025-08-20 23:50:16 UTC to 2025-08-13 21:41:46 UTC - Support building books using mdbook in main (v0.5.x) (rust-lang/rust-by-example#1952) - Improve the hints in `fmt` (1.2.3. Formatting); mention type casting (rust-lang/rust-by-example#1951)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.