You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rustc will recommend the non-existent use statement use std::os::ext::process::CommandExt;, if the CommandExt trait is used, but not in scope.
Consider the following minimal example, a program that we would like to exec true:
use std::process::Command;fnmain(){let err = Command::new("true").exec();panic!(err)}
This shouldn't compile, as the CommandExt trait, which .exec is part of, is not in scope. rustc says as much:
» rustc execit.rs
error[E0599]: no method named `exec` found for type `std::process::Command` in the current scope
--> execit.rs:4:36
|
4 | let err = Command::new("true").exec();
| ^^^^
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
candidate #1: `use std::os::ext::process::CommandExt;`
error: aborting due to previous error
Let's take the compiler's suggestion, since it is correct — a required trait is indeed not in scope:
» cat execit.rs
use std::process::Command;
use std::os::ext::process::CommandExt;
fn main() {
let err = Command::new("true").exec();
panic!(err)
}
» rustc execit.rs
error[E0432]: unresolved import `std::os::ext`
--> execit.rs:2:14
|
2 | use std::os::ext::process::CommandExt;
| ^^^ Could not find `ext` in `os`
warning: unused import: `std::os::ext::process::CommandExt`
--> execit.rs:2:5
|
2 | use std::os::ext::process::CommandExt;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
error[E0599]: no method named `exec` found for type `std::process::Command` in the current scope
--> execit.rs:5:36
|
5 | let err = Command::new("true").exec();
| ^^^^
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
candidate #1: `use std::os::ext::process::CommandExt;`
error: aborting due to 2 previous errors
… it both fails to resolve the import, and re-recommends that very import in the same output.
I'm not sure how rustc forms its candidates for missing use statements (which are normally spot-on suggestion, BTW) but this particular one is bugged (and somewhat wat-inducing).
The docs for Command link to std::os::unix::process::CommandExt, and indeed, that compiles:
» cat execit.rs
use std::process::Command;
use std::os::unix::process::CommandExt;
fn main() {
let err = Command::new("true").exec();
panic!(err)
}
» rustc execit.rs
» # success!
The text was updated successfully, but these errors were encountered:
rustc
will recommend the non-existent use statementuse std::os::ext::process::CommandExt;
, if theCommandExt
trait is used, but not in scope.Consider the following minimal example, a program that we would like to exec
true
:This shouldn't compile, as the
CommandExt
trait, which.exec
is part of, is not in scope.rustc
says as much:Let's take the compiler's suggestion, since it is correct — a required trait is indeed not in scope:
… it both fails to resolve the import, and re-recommends that very import in the same output.
I'm not sure how
rustc
forms its candidates for missinguse
statements (which are normally spot-on suggestion, BTW) but this particular one is bugged (and somewhat wat-inducing).The docs for
Command
link tostd::os::unix::process::CommandExt
, and indeed, that compiles:The text was updated successfully, but these errors were encountered: