Strange formatting of complex generics and `impl` types
Open
Nobody has claimed this yet.
A-generics
A-trait-bounds
C-bug
I-poor-formatting
I-vertical-alignment
S-has-mcve
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I would expect either
pub fn layer(
state: Arc<State>,
) -> impl Layer<
Route,
Service = impl Clone
+ Service<
Request<Body>,
Response = Response,
Future = impl Send,
Error = std::convert::Infallible,
>,
> + Clone {
}
or
pub fn layer(
state: Arc<State>,
) -> impl Layer<
Route,
Service = impl Clone + Service<
Request<Body>,
Response = Response,
Future = impl Send,
Error = std::convert::Infallible,
>,
> + Clone {
}
but I get
pub fn layer(
state: Arc<State>,
) -> impl Layer<
Route,
Service = impl Clone
+ Service<
Request<Body>,
Response = Response,
Future = impl Send,
Error = std::convert::Infallible,
>,
> + Clone {
}
What is the + Service< even supposed to be aligned to? This seems wrong.
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
Open the linked Rust Playground reproduction and compare rustfmt's output with the two expected formatting examples in the issue. Trace the formatting behavior for nested generics and impl types, then verify that the reproduced signature no longer receives the unexpected alignment; no specific source file or test is named.
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
- 42/100