Skip to content

Rustfmt generates invalid code for associated type bounds with where-clause and comments #6761

Description

@taiheioki

Input (Playground):

pub trait Trait {
    type I: Iterator<
        // This is an item
        Item = Self,
    >
    where
        Self: Copy;
}

Expected: rustfmt produces the same code as input.

Output: rustfmt produces the following invalid code

pub trait Trait {
    type I: Iterator<
        // This is an item
        Item = Self,
    >
    : Iterator<
    // This is an item
    Item = Self,
    >
    where
        Self: Copy;
}

Version

$ rustfmt --version
rustfmt 1.8.0-stable (ded5c06cf2 2025-12-08)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions