Rustfmt duplicate associated type bound in the presence of comment
Open
Nobody has claimed this yet.
A-associated-type-bounds
A-comments
C-bug
I-invalid-code
S-has-mcve
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I tried this code:
trait Foo {
type Bar<'a>: Baz1 //
where Self: 'a;
}
Run rustfmt
trait Foo {
type Bar<'a>: Baz1
: Baz1 //
where
Self: 'a;
}
Can reproduce without <'a>, but the code would be pointless in that case.
Somewhat related: comment is discarded
trait Foo {
type Bar: Baz1 // what
;
}
Run rustfmt
trait Foo {
type Bar: Baz1;
}
Meta
rustfmt 1.7.1-nightly (35b658f 2024-07-08)
Backtrace
<backtrace>
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
Start by running rustfmt 1.7.1-nightly on the two Rust snippets in the issue and compare the output with the reported results. Trace the formatter path handling associated type bounds, lifetimes, and comments. Done means the duplicate Baz1 bound is not emitted and the inline comment is preserved appropriately.
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