Skip to content

Taplo fails to sort when subtables are out of order #829

@mmottl

Description

@mmottl

The dependencies table will not be sorted by Taplo in the following Cargo.toml file, leaving c and b out of order:

[package]
name = "foo"

[dependencies]
a = { workspace = true }
c = { workspace = true }
b = { workspace = true }

[package.metadata.cargo-machete]
ignored = ["serde"]

But if we simply move the subtable package.metadata.cargo-machete before dependencies as in:

[package]
name = "foo"

[package.metadata.cargo-machete]
ignored = ["serde"]

[dependencies]
a = { workspace = true }
c = { workspace = true }
b = { workspace = true }

Then taplo format Cargo.toml will reorder c and b as required.

Our .taplo.toml configuration:

# General

[formatting]
reorder_arrays = true
reorder_keys = true

# Cargo.toml

[[rule]]
include = ["**/Cargo.toml"]
keys = [
  "bench",
  "package",
  "workspace.lints.clippy",
  "workspace.lints.rust",
  "workspace.package",
]

[rule.formatting]
reorder_keys = false

# pyproject.toml

[[rule]]
include = ["**/pyproject.toml"]
keys = ["project", "tool.poetry"]

[rule.formatting]
reorder_keys = false

# wrangler.toml

[[rule]]
include = ["**/wrangler.toml"]

[rule.formatting]
reorder_keys = false

Taplo version:

❯ taplo --version
taplo 0.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions