Skip to content

Wrongly positioned "+ Send + Sync + 'static" in complex bound. #6948

Description

@kanashimia

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-boundsArea: trait boundsA-whitespaceArea: whitespace and its handlingC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEI-vertical-alignmentIssue: poor vertical alignment

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions