Skip to content

cargo fmt doesn't respect the passed files #30

Closed
@zimbatm

Description

@zimbatm

cargo fmt parses the Cargo.toml and then generates its own list of files to format.

$ strace -f -e execve -s 4096 cargo fmt -- src/customlog.rs 
execve("/nix/store/lw6s4749i3z2kpg26742ivjcq746jvv2-devshell-dir/bin/cargo", ["cargo", "fmt", "--", "src/customlog.rs"], 0x7ffd5c548050 /* 82 vars */) = 0
execve("/nix/store/lw6s4749i3z2kpg26742ivjcq746jvv2-devshell-dir/bin/cargo-fmt", ["/nix/store/lw6s4749i3z2kpg26742ivjcq746jvv2-devshell-dir/bin/cargo-fmt", "fmt", "--", "src/customlog.rs"], 0x55be3c2d64c0 /* 85 vars */) = 0
strace: Process 3095549 attached
[pid 3095549] execve("/nix/store/fk9vq870hfgwj8w92r4zysvj3a52mzgh-rust/bin/cargo", ["/nix/store/fk9vq870hfgwj8w92r4zysvj3a52mzgh-rust/bin/cargo", "metadata", "--format-version", "1", "--no-deps", "--offline"], 0x7ffecc7ef7e0 /* 85 vars */) = 0
[pid 3095549] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3095549, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
strace: Process 3095550 attached
[pid 3095550] execve("/nix/store/lw6s4749i3z2kpg26742ivjcq746jvv2-devshell-dir/bin/rustfmt", ["rustfmt", "/home/zimbatm/go/src/github.com/numtide/prjfmt/src/lib.rs", "/home/zimbatm/go/src/github.com/numtide/prjfmt/src/main.rs", "--edition", "2018", "src/customlog.rs"], 0x7ffecc7ef7e0 /* 85 vars */) = 0
[pid 3095550] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3095550, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
+++ exited with 0 +++

You can see that 3095550 rustfmt is being invoked with the list of files of the project, plus the one passed as an argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterIssue specific to a formatter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions