Wrongly positioned "+ Send + Sync + 'static" in complex bound.
Open
Nobody has claimed this yet.
A-trait-bounds
A-whitespace
C-bug
I-vertical-alignment
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Summary
Input code:
pub fn layer<L>(self, layer: L) -> Self
where
L: Layer<
Route,
Service: Service<
Request,
Response: IntoResponse + 'static,
Error: Into<Infallible> + 'static,
Future: Send + 'static,
> + Clone + Send + Sync + 'static,
> + Clone + Send + Sync + 'static,
{
map_inner!(self, this => RouterInner {
path_router: this.path_router.layer(layer.clone()),
default_fallback: this.default_fallback,
catch_all_fallback: this.catch_all_fallback.map(|route| route.layer(layer)),
})
}
What rustfmt formats it as:
pub fn layer<L>(self, layer: L) -> Self
where
L: Layer<
Route,
Service: Service<
Request,
Response: IntoResponse + 'static,
Error: Into<Infallible> + 'static,
Future: Send + 'static,
> + Clone
+ Send
+ Sync
+ 'static,
> + Clone
+ Send
+ Sync
+ 'static,
{
map_inner!(self, this => RouterInner {
path_router: this.path_router.layer(layer.clone()),
default_fallback: this.default_fallback,
catch_all_fallback: this.catch_all_fallback.map(|route| route.layer(layer)),
})
}
Configuration
rustfmt --version:
rustfmt 1.9.0-nightly (9eb3be26b4 2026-05-18)
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
No source file or test is named. Start by running the supplied Rust reproducer through the reported rustfmt version and compare its formatting with the input. Trace the formatter path for the nested where-clause bounds; done means the + Send + Sync + 'static bounds are positioned correctly rather than expanded at the wrong nesting level.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 57/100