Skip to content

cargo add should check [dependencies] and [dependencies.*] sections separately when determining whether it was sorted #11584

@figsoda

Description

@figsoda

Problem

Here is an example Cargo.toml, I will omit the package section from now on

[package]
name = "foo"
version = "0.1.0"
edition = "2021"

[dependencies]
rand = "*"
serde = "*"

[dependencies.cfg-if]
version = "*"

When I run cargo add libc, I get

[dependencies]
rand = "*"
serde = "*"
libc = "0.2.139"

[dependencies.cfg-if]
version = "*"

instead of

[dependencies]
libc = "0.2.139"
rand = "*"
serde = "*"

[dependencies.cfg-if]
version = "*"

since cfg-if goes after serde and cargo add thinks the dependencies are unsorted

Steps

No response

Possible Solution(s)

check the sorting of the [dependencies] section and the [dependencies.*] sections separately, the same applies for build and dev dependencies

Notes

No response

Version

cargo 1.68.0-nightly (d992ab4e9 2023-01-10)
release: 1.68.0-nightly
commit-hash: d992ab4e9034930e7809749f04077045af8f4d79
commit-date: 2023-01-10
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:OpenSSL/1.1.1q)
os: NixOS 23.5.0 [64-bit]


<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"hi-rustin"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions