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 /tests/ui/rust-2024 | |
| parent | fbce03b195c02e425fbb12276b8f02349048a75f (diff) | |
| download | rust-5ae03863ded632b6cedeed29cc53e9c69fe5b56b.tar.gz rust-5ae03863ded632b6cedeed29cc53e9c69fe5b56b.zip | |
CommandExt::before_exec: deprecate safety in edition 2024
Diffstat (limited to 'tests/ui/rust-2024')
| -rw-r--r-- | tests/ui/rust-2024/unsafe-before_exec.e2024.stderr | 11 | ||||
| -rw-r--r-- | tests/ui/rust-2024/unsafe-before_exec.rs | 17 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/rust-2024/unsafe-before_exec.e2024.stderr b/tests/ui/rust-2024/unsafe-before_exec.e2024.stderr new file mode 100644 index 00000000000..2798ccdefd0 --- /dev/null +++ b/tests/ui/rust-2024/unsafe-before_exec.e2024.stderr @@ -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`. diff --git a/tests/ui/rust-2024/unsafe-before_exec.rs b/tests/ui/rust-2024/unsafe-before_exec.rs new file mode 100644 index 00000000000..540394da80e --- /dev/null +++ b/tests/ui/rust-2024/unsafe-before_exec.rs @@ -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. +} |
