diff options
| author | Ralf Jung <post@ralfj.de> | 2024-06-04 11:50:18 +0200 | 
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-08-14 14:04:11 +0200 | 
| commit | 5ae03863ded632b6cedeed29cc53e9c69fe5b56b (patch) | |
| tree | 779a156e744778269a0636157c12b02219b9f800 /library/std/src/os/unix/process.rs | |
| parent | fbce03b195c02e425fbb12276b8f02349048a75f (diff) | |
| download | rust-5ae03863ded632b6cedeed29cc53e9c69fe5b56b.tar.gz rust-5ae03863ded632b6cedeed29cc53e9c69fe5b56b.zip | |
CommandExt::before_exec: deprecate safety in edition 2024
Diffstat (limited to 'library/std/src/os/unix/process.rs')
| -rw-r--r-- | library/std/src/os/unix/process.rs | 14 | 
1 files changed, 11 insertions, 3 deletions
| diff --git a/library/std/src/os/unix/process.rs b/library/std/src/os/unix/process.rs index c53423675bd..46202441d4e 100644 --- a/library/std/src/os/unix/process.rs +++ b/library/std/src/os/unix/process.rs @@ -109,13 +109,21 @@ pub trait CommandExt: Sealed { /// Schedules a closure to be run just before the `exec` function is /// invoked. /// - /// This method is stable and usable, but it should be unsafe. To fix - /// that, it got deprecated in favor of the unsafe [`pre_exec`]. + /// `before_exec` used to be a safe method, but it needs to be unsafe since the closure may only + /// perform operations that are *async-signal-safe*. Hence it got deprecated in favor of the + /// unsafe [`pre_exec`]. Meanwhile, Rust gained the ability to make an existing safe method + /// fully unsafe in a new edition, which is how `before_exec` became `unsafe`. It still also + /// remains deprecated; `pre_exec` should be used instead. /// /// [`pre_exec`]: CommandExt::pre_exec #[stable(feature = "process_exec", since = "1.15.0")] #[deprecated(since = "1.37.0", note = "should be unsafe, use `pre_exec` instead")] - fn before_exec<F>(&mut self, f: F) -> &mut process::Command + #[cfg_attr(bootstrap, rustc_deprecated_safe_2024)] + #[cfg_attr( + not(bootstrap), + rustc_deprecated_safe_2024(audit_that = "the closure is async-signal-safe") + )] + unsafe fn before_exec<F>(&mut self, f: F) -> &mut process::Command where F: FnMut() -> io::Result<()> + Send + Sync + 'static, { | 
