Skip to content

Cannot use cargo_bin! without triggering deprecation warning for cargo_bin #258

@asomers

Description

@asomers

In assert_cmd 2.1.0, the assert_cmd::cargo::cargo_bin function is deprecated, and the help text recommends to use cargo::cargo_bin! instead. However, the function and the macro both have the same name, so it's impossible to import one without the other.

For example:

use assert_cmd::{cargo::cargo_bin, prelude::*};

...
    let cmd = Command::new(cargo_bin!("fsx"))
...

Compiling this code will result in the error:

warning: use of deprecated function `assert_cmd::cargo::cargo_bin`: incompatible with a custom cargo build-dir, see instead `cargo::cargo_bin!`
 --> tests/integration.rs:5:25
  |
5 | use assert_cmd::{cargo::cargo_bin, prelude::*};
  |                         ^^^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default

It's still possible to use the macro, if it's imported with the old-fashioned #[macro_use] syntax, like below. However, the suggestion to use cargo::cargo_bin! suggests that the old-fashioned syntax is not intended. And indeed, the doc tests don't use it: https://docs.rs/assert_cmd/latest/assert_cmd/cargo/macro.cargo_bin.html#example .

#[macro_use] extern crate assert_cmd;

What's the recommended way to use the cargo_bin! macro without triggering the deprecation warning?

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