Skip to content

Rustfmt misaligns doc comment between rustfmt::skip modules #6176

Description

@dtolnay
mod modules {
    #[rustfmt::skip]
    #[path = "/dev/null"]
    mod first;

    /// ...
    /// ...
    #[rustfmt::skip]
    #[path = "/dev/null"]
    mod second;
}

Running rustfmt on this file turns it into:

mod modules {
    #[rustfmt::skip]
    #[path = "/dev/null"]
    mod first; /// ...
               /// ...
    #[rustfmt::skip]
    #[path = "/dev/null"]
    mod second;
}
<     mod first;
<
<     /// ...
<     /// ...
---
>     mod first; /// ...
>                /// ...

Observations:

  • The #[path = "/dev/null"] attribute is not necessary for the repro. It is just to make this reproducible with a single input file.
  • Both #[rustfmt::skip] are necessary for the repro. Without either one, the problem does not occur.
  • Both ; are necessary for the repro. If either module uses {} instead of ;, the problem does not occur.
  • The outer module is necessary.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-commentsArea: commentsA-rustfmt::skipArea: `rustfmt::skip` tool attribute

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions