Custom attributes sometimes not formatted
Open
Nobody has claimed this yet.
E-help-wanted
I-poor-formatting
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
rustfmt 1.4.5-nightly (2019-08-19 9792ff0)
enum E {
#[error(display = "invalid max keyframe interval {} (expected > 0, < {})", _0, i32::max_value() as u64)]
InvalidMaxKeyFrameInterval(u64),
#[error(display = "invalid max keyframe interval {} (expected > 0, < {})", _0, i32::max_value())]
InvalidMaxKeyFrameInterval(u64),
}
gets reformatted as
enum E {
#[error(display = "invalid max keyframe interval {} (expected > 0, < {})", _0, i32::max_value() as u64)]
InvalidMaxKeyFrameInterval(u64),
#[error(
display = "invalid max keyframe interval {} (expected > 0, < {})",
_0,
i32::max_value()
)]
InvalidMaxKeyFrameInterval(u64),
}
even though this also fits fine
enum E {
#[error(
display = "invalid max keyframe interval {} (expected > 0, < {})",
_0,
i32::max_value() as u64
)]
InvalidMaxKeyFrameInterval(u64),
#[error(
display = "invalid max keyframe interval {} (expected > 0, < {})",
_0,
i32::max_value()
)]
InvalidMaxKeyFrameInterval(u64),
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the Rust enum snippets and compare rustfmt's handling of the two custom attributes. Start by tracing custom attribute formatting in the rustfmt codebase; done means equivalent attributes are formatted consistently when either expression fits within the available width.
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
- 45/100