Skip to content

Commit

Permalink
tests: adjust tests/ui/issues/issue-39175.rs
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
jieyouxu committed Jan 23, 2025
1 parent 669f4bc commit eee72ba
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
16 changes: 16 additions & 0 deletions tests/ui/issues/issue-39175.fixed
Original file line number Diff line number Diff line change
@@ -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`
}
7 changes: 3 additions & 4 deletions tests/ui/issues/issue-39175.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
6 changes: 3 additions & 3 deletions tests/ui/issues/issue-39175.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit eee72ba

Please sign in to comment.