Skip to content

ignore is overwritten in nested rustfmt.toml layouts #3881

Closed
@pyrrho

Description

@pyrrho

Given a layout like,

my-crate
├── rusfmt.toml
└── src
    ├── lib.rs
    └── sub
        └── dir
            ├── file-a.rs
            ├── file-b.rs
            └── rustfmt.toml

where my-crate/rustfmt.toml include ignore = ["src/sub/dir/file-a.rs"] and my-crate/src/sub/dir/rustfmt.toml includes ignore = [], running --print-config current for files in src/sub/dir shows an empty ignore array.

$ rustfmt +nightly --print-config current ./src/sub/dir/file-b.rs | grep ignore
ignore = []

I initially expected the returned config to include "src/sub/dir/file-a.rs".

This was somewhat surprising to me, as the rest of rustfmt.toml "feels" additive to me. I put "feels" in quotations, as child rustfmt.toml files really just overwrite the single-value configurations of their parents. As that's exactly what's going on, this may be correct behavior (if somewhat limiting in atypical repo layouts).

Looking back over the configuration list, it seems ignore is the only configuration that takes a list, and one of two that expects a path (the other being license_template_path).

I would consider it an improvement if,

  1. ignore arrays were union'd together as rustfmt assembled it's 'current' configuration
  2. --print-config current emitted absolute-resolved paths (in addition to, or in place of relative paths)

I'm pairing these two features together specifically because I think it would be necessary to resolve paths into an absolute form in order to union them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions