Skip to content

Cargo fmt incorrectly formats macro commands #77

@avi-cenna

Description

@avi-cenna

Hi,

I was trying to play around with the following example from the docs, and I noticed that cargo fmt was putting a space between the two hyphens in --version.

use anyhow::Result;
use cmd_lib::run_fun;

fn main() -> Result<()> {
    let version = run_fun!(rustc - -version)?; // cargo fmt messes this line up
    println!("Your rust version is {}", version);

    // with pipes
    let n = run_fun!(echo "the quick brown fox jumped over the lazy dog" | wc -w)?;
    println!("There are {} words in above sentence", n);

    println!("Hello, world!");

    Ok(())
}

If I do this, cargo fmt doesn't mess with the syntax.

let version = run_fun!(rustc "--version")?;
println!("Your rust version is {}", version);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions