Skip all attributes with a common module prefix
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I'm using the rstest crate for unit testing. This crate defines a case attribute that can be suffixed with arbitrary identifiers to name individual test cases, like this:
#[rstest]
#[case::negative_value(-5, 25)]
#[case::zero(0, 0)]
#[case::positive_value(3, 9)]
#[case::large_value(10000, 100000000)]
fn squares_the_value(#[case] value: i32, #[case] expected: i32) {
assert_eq!(square(value), expected);
}
In some situations, I prefer to manually format these case definitions. However, I can't find a good way to exempt them from formatting. I tried #[rustfmt::skip::attributes(case)], but that will only skip attributes that are named exactly case, not case::xxx.
Is there an existing way to exclude the case::xxx attributes from being formatted, without excluding the following function?
The best I could come up with was some sort of wildcard support, like this: #[rustfmt::skip::attributes(case::*)].
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 using the rstest example and rustfmt::skip::attributes(case), then compare that behavior with the requested case::* prefix matching. The change is done when prefixed case attributes can be excluded from formatting without excluding the following function; the payload does not identify implementation files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100