Skip to content

cargo fmt --package: not a member of workspace (Implicit workspace) #3643

Closed
@kuviman

Description

@kuviman

Tested both in current stable & nightly

$ rustup run stable cargo fmt --version
<No output: bug?>
$ rustup run stable rustfmt --version
rustfmt 1.2.0-stable (09940a7 2019-03-27)
$ rustup run nightly cargo fmt --version
rustfmt 1.3.0-nightly (d334502 2019-06-09)

Steps to reproduce

  1. cargo new cargo-fmt-test && cd cargo-fmt-test
  2. cargo new --lib --name dependency-crate-name dependency-dir-name
  3. Add dependency-crate-name = { path = "dependency-dir-name" } to dependencies in Cargo.toml

So, we have a path dependency with a directory name different than crate name. Looks like it is only broken if names differ.

Also, these steps do not create [workspace] section in Cargo.toml, so this is an implicit workspace or something. If [workspace] is present, then it looks like cargo fmt works correctly.

cargo fmt --all

$ cargo fmt --all -v
[bin (2018)] "/home/kuviman/Temp/cargo-fmt-test/src/main.rs"
rustfmt --edition 2018 /home/kuviman/Temp/cargo-fmt-test/src/main.rs

^This should format the dependency as well, but it does not

cargo fmt --package dependency-crate-name

$ cargo fmt --package dependency-crate-name
package `dependency-dir-name` is not a member of the workspace
usage: cargo fmt [options]
<...>

^ So, cargo-fmt does not see the dependency as part of the workspace.
Also there is usage output for some reason

Default cargo subcommands do work (like cargo test --package dependency-crate-name).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.good first issueIssues up for grabs, also good candidates for new rustfmt contributors

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions