Skip to content

Rustfmt incorrectly strips comments when removing empty where clause #4649

Open
@vallentin

Description

@vallentin

Empty where clauses are semantically valid Rust. However rustfmt incorrectly removes them and comments.

Before:

trait Foo {
    fn bar(&self)
    where
    //     Self: Bar
    // Some comment
    ;
}

fn foo<T>()
where
//     T: Bar,
// Some comment
{
    println!("foo");
}

After:

trait Foo {
    fn bar(&self);
}

fn foo<T>() {
    println!("foo");
}

rustfmt 1.4.25-stable (0f29ff6 2020-11-11)
I also tested it on master a97fd77

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions