-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CommandExt::before_exec: deprecate safety in edition 2024
- Loading branch information
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0133]: call to unsafe function `before_exec` is unsafe and requires unsafe block | ||
--> $DIR/unsafe-before_exec.rs:14:5 | ||
| | ||
LL | cmd.before_exec(|| Ok(())); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | ||
| | ||
= note: consult the function's documentation for information on how to avoid undefined behavior | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0133`. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//@ revisions: e2021 e2024 | ||
//@ only-unix | ||
//@[e2021] edition: 2021 | ||
//@[e2021] check-pass | ||
//@[e2024] edition: 2024 | ||
//@[e2024] compile-flags: -Zunstable-options | ||
|
||
use std::process::Command; | ||
use std::os::unix::process::CommandExt; | ||
|
||
#[allow(deprecated)] | ||
fn main() { | ||
let mut cmd = Command::new("sleep"); | ||
cmd.before_exec(|| Ok(())); | ||
//[e2024]~^ ERROR call to unsafe function `before_exec` is unsafe | ||
drop(cmd); // we don't actually run the command. | ||
} |