rust-lang / rust-lang/rustfmt

Generating config file includes all unstable features and generates bunch of warnings

Open
#5,594 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-cli A-config A-stability C-bug
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

I have tried to search issues and reading README / website but I did not find any help for this issue. I'm not sure if this is a bug or intended to work this way.

In short:

  1. Generated rustfmt.toml
  2. Tried to format project
  3. Got a lot warnings

Longer explanation

Readme has this tip:

When you run rustfmt, place a file named rustfmt.toml or .rustfmt.toml in target file directory or its parents to override the default settings of rustfmt. You can generate a file containing the default configuration with rustfmt --print-config default rustfmt.toml and customize as needed.

When I run that command or cargo fmt -- --print-config default .rustfmt.toml, and after that run cargo fmt I get a lot warnings that this and that configuration option is not available.

For example this

Warning: can't set where_single_line = false, unstable features are only available in nightly channel.

Is is intended that print-config command generates config file that does not work with stable toolchain or with unstable features disabled? I would have expected that if I run that command with stable toolchain, it would generate config file that then works and includes only stable features.

Another minor thing that feels weird, is that the edition setting was set to 2015 even though Cargo.toml is set to 2021. :)

Versions:

> cargo fmt --version                              
rustfmt 1.5.1-stable (897e3755 2022-11-02)

> cargo --version
cargo 1.65.0 (4bc8f24d3 2022-10-20)

MacOS 12.6

I can provide more information if needed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing rustfmt --print-config default rustfmt.toml and cargo fmt -- --print-config default .rustfmt.toml with the reported stable versions. Inspect the print-config implementation and its tests, then verify whether generated configuration should exclude unavailable unstable options and reflect the project's edition without warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.