Skip to content

Format members Array of Cargo.toml in workspace #15084

Open
@detoxifiedplant

Description

@detoxifiedplant

Problem

While adding new members with cargo new member_name in a workspace, the members list should be updated with the new member being added.

Current implementation sorts the members list upon adding new member. Prefix of " "(an empty space) gets added before name of each member/display_path resulting in improper formatted output of members list.

Executing mentioned steps should result in Cargo.toml file as below

[workspace]
members = [ "crates/lib_auth","crates/lib_core"]

The members list have inconsistent format.
Correct Format:

[workspace]
members = ["crates/lib_auth", "crates/lib_core"]

Steps

  1. mkdir work_space
  2. cd work_space
  3. echo "[workspace]" > Cargo.toml
  4. cargo new crates/lib_core
  5. cargo new crates/lib_auth

Possible Solution(s)

Format the members list which is Array struct of toml_edit lib.

I have fixed the issue and have raised the PR.

Notes

No response

Version

cargo 1.84.0 (66221abde 2024-11-19)
release: 1.84.0
commit-hash: 66221abdeca2002d318fde6efff516aab091df0e
commit-date: 2024-11-19
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Arch Linux [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions