From eee72ba2f1a87f88be7a9da127705c1ad0aea6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Thu, 23 Jan 2025 15:25:18 +0800 Subject: [PATCH] tests: adjust `tests/ui/issues/issue-39175.rs` - Change test to check only. - Don't ignore `wasm` or `sgx`. - Gate test to be Unix only because Unix `CommandExt` influences the suggestion. - Run rustfix on the suggestion. --- tests/ui/issues/issue-39175.fixed | 16 ++++++++++++++++ tests/ui/issues/issue-39175.rs | 7 +++---- tests/ui/issues/issue-39175.stderr | 6 +++--- 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 tests/ui/issues/issue-39175.fixed diff --git a/tests/ui/issues/issue-39175.fixed b/tests/ui/issues/issue-39175.fixed new file mode 100644 index 000000000000..1f2b5b8b0ce6 --- /dev/null +++ b/tests/ui/issues/issue-39175.fixed @@ -0,0 +1,16 @@ +// This test ignores some platforms as the particular extension trait used +// to demonstrate the issue is only available on unix. This is fine as +// the fix to suggested paths is not platform-dependent and will apply on +// these platforms also. + +//@ run-rustfix +//@ only-unix (the diagnostics is influenced by `use std::os::unix::process::CommandExt;`) + +use std::os::unix::process::CommandExt; +use std::process::Command; +// use std::os::unix::process::CommandExt; + +fn main() { + let _ = Command::new("echo").arg("hello").exec(); +//~^ ERROR no method named `exec` +} diff --git a/tests/ui/issues/issue-39175.rs b/tests/ui/issues/issue-39175.rs index 7b801317b714..a7e6134b2d9c 100644 --- a/tests/ui/issues/issue-39175.rs +++ b/tests/ui/issues/issue-39175.rs @@ -3,14 +3,13 @@ // the fix to suggested paths is not platform-dependent and will apply on // these platforms also. -//@ ignore-windows -//@ ignore-wasm32 no processes -//@ ignore-sgx no processes +//@ run-rustfix +//@ only-unix (the diagnostics is influenced by `use std::os::unix::process::CommandExt;`) use std::process::Command; // use std::os::unix::process::CommandExt; fn main() { - Command::new("echo").arg("hello").exec(); + let _ = Command::new("echo").arg("hello").exec(); //~^ ERROR no method named `exec` } diff --git a/tests/ui/issues/issue-39175.stderr b/tests/ui/issues/issue-39175.stderr index bbe8badb6523..163b4989aae0 100644 --- a/tests/ui/issues/issue-39175.stderr +++ b/tests/ui/issues/issue-39175.stderr @@ -1,8 +1,8 @@ error[E0599]: no method named `exec` found for mutable reference `&mut Command` in the current scope - --> $DIR/issue-39175.rs:14:39 + --> $DIR/issue-39175.rs:13:47 | -LL | Command::new("echo").arg("hello").exec(); - | ^^^^ +LL | let _ = Command::new("echo").arg("hello").exec(); + | ^^^^ | = help: items from traits can only be used if the trait is in scope help: there is a method `pre_exec` with a similar name, but with different arguments