Skip to content

Unclear intent of Cargo.toml sorting #29

@scop

Description

@scop

Describe the bug

dprint-plugin-toml version: 0.7..0

Per cargo.applyConventions (default true) current docs, "Whether to apply sorting to a Cargo.toml file."

It's kind of vague what kind of sorting this actually means, but at least for the example Cargo.toml below, the sorted result is neither alphabetical nor the one for the keys listing at https://doc.rust-lang.org/cargo/reference/manifest.html#the-homepage-field

I don't personally have that strong opinion about the format, but if I were to start a tool like this, I'd make it sort keys the same as they are in the above manifest doc.

But if the current sorting is there to stay and intentional, perhaps amend the docs a bit about what kind of sorting to expect, even if it's just "Whether to apply opinionated sorting to a Cargo.toml file." (emphasis just to highlight).

Input Code

[package]
name = "..."
version = "..."
authors = ["..."]
edition = "..."
description = "..."
repository = "..."
license = "..."

Expected Output

(unchanged)

Actual Output

--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,5 +5,5 @@ authors = ["..."]
 edition = "..."
-description = "..."
-repository = "..."
 license = "..."
+repository = "..."
+description = "..."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions