rust-lang / rust-lang/rustfmt

[enh] Merge and sort comma-separated attribute parameters for known attributes

Open
#5,548 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

I would like to propose cargo fmt to merge and sort attribute params in cases where the attribute is well known and wouldn't cause any behavioral changes (?):

From:

#![allow(unused_variables, unused_imports, unused_macros)]
#![allow(clippy::eq_op)]
#![allow(clippy::format_in_format_args)]
#![allow(clippy::print_literal)]
#![allow(named_arguments_used_positionally)]

into

#![allow(
    clippy::eq_op,
    clippy::format_in_format_args,
    clippy::print_literal,
    named_arguments_used_positionally,
    unused_imports,
    unused_macros,
    unused_variables
)]

P.S. Should this be a fmt or a clippy action?

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

Use the examples in the issue as initial acceptance cases. First determine whether this belongs in rustfmt or clippy, then identify the existing attribute-formatting tests; done means known comma-separated parameters are merged and sorted without behavioral changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.