rust-lang / rust-lang/rustfmt

Macro attributes containing consts not formatted correctly

Open
#6,374 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

A real-world example from nutype:

This gets formatted just fine:

#[nutype(validate(len_char_min = 5, len_char_max = 20))]
struct Email(String);

But this does not:

#[nutype(validate(len_char_min = 5, len_char_max = 20, regex = EMAIL_REGEX))]
struct Email(String);

It looks like that rustfmt is not liking the EMAIL_REGEX here, but I'm not sure why.

Tested on rustfmt 1.8.0-nightly (3ed6e3cc69 2024-10-17).

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

The issue names no source file, test, or entry point. Reproduce both nutype examples with rustfmt 1.8.0-nightly and compare their output; done means the const-valued macro attribute formats correctly without regressing the first example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.