Skip to content

removes comment after import #7051

Open

Description

@matthiaskrgr
use std /* goodbye */;

rustfmt a.rs
=>

use std;

I would expect the comment to stay 🤔

rustfmt 1.10.0-nightly (c54751567b 2026-08-22)

Activity

  1. added
    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE
    on Aug 23, 2026
  2. added
    needs-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.
    on Aug 23, 2026
  3. matthiaskrgr commented on Aug 23, 2026

    @matthiaskrgr
    MemberAuthor

    same for

    use std // bye
    ;
  4. added
    I-unexpectedly-removes-codeIssue: unexpectedly removes code that we should not be removing
    A-importsArea: imports, e.g. `use` syntax
    and removed
    needs-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.
    on Aug 24, 2026
  5. ytmimi commented on Aug 24, 2026

    @ytmimi
    Contributor

    Pretty sure we'd just need to add comment recovery code here:

    rustfmt/src/imports.rs

    Lines 347 to 355 in bbfd120

    let use_str = self
    .rewrite_result(context, shape.offset_left(vis.len(), self.span())?)
    .map(|s| {
    if s.is_empty() {
    s
    } else {
    format!("{}use {};", vis, s)
    }
    })?;

  6. added
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    on Aug 24, 2026
  7. anisayakmitra-in commented on Aug 28, 2026

    @anisayakmitra-in

    I would like to work on this and add regression coverage for both block and line comments around the import semicolon. I use Codex as an AI coding assistant and will review, test, and be able to explain the complete change. Under the Rust project LLM policy and the E-easy restriction, may I have maintainer approval to use that assistance for this issue before I begin?

  8. ytmimi commented on Aug 28, 2026

    @ytmimi
    Contributor

    It's okay if you use an LLM to assist you, but please review the code before submitting it for review to make sure it's high quality. Please disclose how much of the code was LLM generated. Also, make sure that PR descriptions and any back and forth discussion on the PR is 100% written by you.

  9. Andrew-Velox commented on Oct 7, 2026

    @Andrew-Velox

    It looks like the previous PR was closed. I would like to work on this, can I have a try?

  10. Andrew-Velox commented on Oct 7, 2026

    @Andrew-Velox

    @rustbot claim

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

Metadata

Metadata

Assignees

Labels

A-commentsArea: commentsA-importsArea: imports, e.g. `use` syntaxC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.I-unexpectedly-removes-codeIssue: unexpectedly removes code that we should not be removing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions