CommandExt::before_exec: deprecate safety in edition 2024 · patricklam/verify-rust-std@23d1309 (original) (raw)

`@@ -109,13 +109,21 @@ pub trait CommandExt: Sealed {

`

109

109

`` /// Schedules a closure to be run just before the exec function is

``

110

110

`/// invoked.

`

111

111

`///

`

112

``

`-

/// This method is stable and usable, but it should be unsafe. To fix

`

113

``

`` -

/// that, it got deprecated in favor of the unsafe [pre_exec].

``

``

112

`` +

/// before_exec used to be a safe method, but it needs to be unsafe since the closure may only

``

``

113

`+

/// perform operations that are async-signal-safe. Hence it got deprecated in favor of the

`

``

114

`` +

/// unsafe [pre_exec]. Meanwhile, Rust gained the ability to make an existing safe method

``

``

115

`` +

/// fully unsafe in a new edition, which is how before_exec became unsafe. It still also

``

``

116

`` +

/// remains deprecated; pre_exec should be used instead.

``

114

117

`///

`

115

118

`` /// [pre_exec]: CommandExt::pre_exec

``

116

119

`#[stable(feature = "process_exec", since = "1.15.0")]

`

117

120

`` #[deprecated(since = "1.37.0", note = "should be unsafe, use pre_exec instead")]

``

118

``

`-

fn before_exec(&mut self, f: F) -> &mut process::Command

`

``

121

`+

#[cfg_attr(bootstrap, rustc_deprecated_safe_2024)]

`

``

122

`+

#[cfg_attr(

`

``

123

`+

not(bootstrap),

`

``

124

`+

rustc_deprecated_safe_2024(audit_that = "the closure is async-signal-safe")

`

``

125

`+

)]

`

``

126

`+

unsafe fn before_exec(&mut self, f: F) -> &mut process::Command

`

119

127

`where

`

120

128

`F: FnMut() -> io::Result<()> + Send + Sync + 'static,

`

121

129

`{

`