macros: Require safe in safe_f! invocations - #5303
Merged
Merged
Conversation
bbd9253 ("macros: Require unsafe in `f!` invocations") made `unsafe` required in `f!`. Do the same for `safe_f!`, requiring a `safe` keyword. Similar to the `f!` changes, the goal is to make it more obvious whether a function is safe or not just by reading the signature. Technically `safe` isn't really required for that because by default functions are safe. However the `unsafe` requirement in `f!` is recent so the extra keyword helps avoid confusion as to whether `pub fn` is safe (default Rust) or unsafe (would previously be the case with `f!`). This also allows us to merge `f!` and `safe_f!` without risk of accidentally making any in-flight patches safe (if they used `f!` before `unsafe` was required).
tgross35
enabled auto-merge
July 21, 2026 19:18
jollaitbot
pushed a commit
to sailfishos-mirror/rust-libc
that referenced
this pull request
Jul 22, 2026
bbd9253 ("macros: Require unsafe in `f!` invocations") made `unsafe` required in `f!`. Do the same for `safe_f!`, requiring a `safe` keyword. Similar to the `f!` changes, the goal is to make it more obvious whether a function is safe or not just by reading the signature. Technically `safe` isn't really required for that because by default functions are safe. However the `unsafe` requirement in `f!` is recent so the extra keyword helps avoid confusion as to whether `pub fn` is safe (default Rust) or unsafe (would previously be the case with `f!`). This also allows us to merge `f!` and `safe_f!` without risk of accidentally making any in-flight patches safe (if they used `f!` before `unsafe` was required). (backport <rust-lang/libc#5303>) (cherry picked from commit c8b6cc2)
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
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.
bbd9253 ("macros: Require unsafe in
f!invocations") madeunsaferequired inf!. Do the same forsafe_f!, requiring asafekeyword.Similar to the
f!changes, the goal is to make it more obvious whether a function is safe or not just by reading the signature. Technicallysafeisn't really required for that because by default functions are safe. However theunsaferequirement inf!is recent so the extra keyword helps avoid confusion as to whetherpub fnis safe (default Rust) or unsafe (would previously be the case withf!).This also allows us to merge
f!andsafe_f!without risk of accidentally making any in-flight patches safe (if they usedf!beforeunsafewas required).