rust-lang / rust-lang/rustfmt

Per-type skip

Open
#3,312 7 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

As discussed in #2924 and "hinted" in #2555 and maybe others, a per-type skip would be nice. I don't have tens of use-case, in fact I have only one: the matrix. In our computer graphic application, we define a lot of matrices in several modules, thus making #[rustfmt::skip] uninteresting. What I (and probably many others) want is something like

// in lib.rs or mod.rs. Or top of a file?
#[rustfmt::skip(Matrix3, Matrix4)]

because I can't imagine a single case where I would want rustfmt to format my matrices. The only right way to format a 3x3 matrix is when it has 3 columns and 3 rows. All in one line or in one row is unreadable.

I don't know rustfmt code at all, nor what it could possibly do. Do you have access to the base type when parsing the files? I ask because I wonder if an alias type Affine = Matrix3<f64> would force the user too add all aliases in the skip, if such a feature existed.

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 reviewing the discussion in issues #2924 and #2555, then trace how rustfmt currently handles #[rustfmt::skip]. Define the behavior for per-type skips, including whether type aliases such as Affine = Matrix3 must be listed, and consider how the requested matrix formatting should be validated.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.