Skip to content

macros: Require safe in safe_f! invocations - #5303

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
tgross35:safe-f
Jul 21, 2026
Merged

macros: Require safe in safe_f! invocations#5303
tgross35 merged 1 commit into
rust-lang:mainfrom
tgross35:safe-f

Conversation

@tgross35

Copy link
Copy Markdown
Contributor

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).

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).
@rustbot

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in an Android module

cc @maurer

Some changes occurred in a NetBSD-like module

cc @semarie

Some changes occurred in an OpenBSD module

cc @semarie

Some changes occurred in a solarish module

cc @jclulow, @pfmooney

@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Jul 21, 2026
@tgross35
tgross35 enabled auto-merge July 21, 2026 19:18
@tgross35
tgross35 added this pull request to the merge queue Jul 21, 2026
Merged via the queue into rust-lang:main with commit c8b6cc2 Jul 21, 2026
57 checks passed
@rustbot rustbot mentioned this pull request Jul 21, 2026
3 tasks
@tgross35
tgross35 deleted the safe-f branch July 21, 2026 19:49
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)
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants