Skip to content

Rust recommends to use a non-existing module #55868

@RalfJung

Description

@RalfJung

The following program:

use std::process::Command;

fn main() {
    Command::new("true")
        .before_exec(|| {})
        .status().unwrap();
}

shows an error saying

error[E0599]: no method named `before_exec` found for type `std::process::Command` in the current scope
 --> src/main.rs:5:10
  |
5 |         .before_exec(|| {})
  |          ^^^^^^^^^^^
  |
  = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
  |
1 | use std::os::ext::process::CommandExt;
  |

However, following that suggestions leads to a program that errors saying

error[E0433]: failed to resolve. Could not find `ext` in `os`
 --> src/main.rs:2:14
  |
2 | use std::os::ext::process::CommandExt;
  |              ^^^ Could not find `ext` in `os`

warning: unused import: `std::os::ext::process::CommandExt`
 --> src/main.rs:2:5
  |
2 | use std::os::ext::process::CommandExt;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

error[E0599]: no method named `before_exec` found for type `std::process::Command` in the current scope
 --> src/main.rs:6:10
  |
6 |         .before_exec(|| {})
  |          ^^^^^^^^^^^
  |
  = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
  |
1 | use std::os::ext::process::CommandExt;
  |

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions