Skip to content

Consider CLI option for cargo.toml path & pull settings out of cargo.toml #4074

Closed
@mitranim

Description

@mitranim

This is based on the discussion in mitranim/sublime-rust-fmt#11. Users expect rustfmt to be run with respect to cargo.toml settings such as edition. Currently rustfmt supports them as CLI options. One option for plugins is to parse cargo.toml, pull out these options and pass them to rustfmt, example: rust-lang/rust-analyzer#2477. I feel like it's the wrong approach. Let's simply pass to rustfmt the location of cargo.toml, and have it pull out any settings it supports.

This way:

  • Users don't need to wait for editor plugins to implement support for new options.
  • Editor plugins don't need to include a TOML parser (huge blocker for mitranim/sublime-rust-fmt since I'd like to avoid dependencies if possible).
  • rustfmt CLI options don't have to grow (maybe).

Speaking of giving rustfmt the config file location. Maybe we could have rustfmt automatically look for all the config files it supports, and simply tell it the innermost directory where to start the search? This way, editor plugins don't have to be updated in the future to support yet another config file. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions