Skip to content

rustfmt removes import if it only contains comments #5899

Open
@ytmimi

Description

@ytmimi

Formatting deletes the import if all of the items are commented out.

Reproducible using rustfmt 1.6.0-nightly (16db2a4b 2023-08-18) and rustfmt 1.5.3-nightly (f4b80cac 2023-06-30). Likely other versions as well.

input

use std::fs::{
    // File
};

output

expect

use std::fs::{
    // File
};

Originally posted by @okaneco in #5852 (comment)

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