Skip to content

cargo-new: workspace is added as an inline table #13345

@weihanglo

Description

@weihanglo

Problem

In #12779, cargo adds new packages to [workspace.members] automatically. This is great when workspace.member array alreay exists, but the format doesn't look good when workspace array is missing.

Steps

  1. cargo new foo && cd foo
  2. cargo add bar --lib

And you'll get the resulting TOML

workspace = { members = ["bar"] }
[package]
name = "foo"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

Possible Solution(s)

Don't add the new package to workspace.members if there is no existing workspace in Cargo.toml.

Notes

No response

Version

cargo 1.77.0-nightly (1ae631085 2024-01-17)
release: 1.77.0-nightly
commit-hash: 1ae631085f01c1a72d05df1ec81f3759a8360042
commit-date: 2024-01-17

Metadata

Metadata

Assignees

Labels

C-bugCategory: bugCommand-newS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions