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.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2025-01-23 15:25:18 +08:00
parent 669f4bce4d
commit eee72ba2f1
3 changed files with 22 additions and 7 deletions

View file

@ -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`
}

View file

@ -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`
}

View file

@ -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