Skip to content

Rustfmt should add enforce a single empty line before a doc comment #4781

@Hofer-Julian

Description

@Hofer-Julian

Input

use std::cell::RefCell;
/// Main function
fn main() {
    let a = RefCell::new(2);
    dbg!(a);
}

Output

use std::cell::RefCell;
/// Main function
fn main() {
    let a = RefCell::new(2);
    dbg!(a);
}

Expected output

use std::cell::RefCell;

/// Main function
fn main() {
    let a = RefCell::new(2);
    dbg!(a);
}

Meta

  • rustfmt version: rustfmt 1.4.30-stable
  • From where did you install rustfmt?: rustup

CC @GuillaumeGomez

Activity

calebcartwright

calebcartwright commented on Apr 4, 2021

@calebcartwright
Member

Thanks for reaching out with your request, but in my opinion this seems like a case best left to the developer. This starts to get tricky when you consider other cases, such as nested items, where some folks would not want the newline insertion.

If anyone feels strongly enough about this feature and is willing to open a PR then I'll certainly take it under consideration, but I do not envision the rustfmt team ever getting around to working on this ourselves.

Have updated the issue labels accordingly.

Hofer-Julian

Hofer-Julian commented on Apr 4, 2021

@Hofer-Julian
Author

Thanks for the clarification @calebcartwright!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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

        Participants

        @calebcartwright@ytmimi@Hofer-Julian

        Issue actions

          Rustfmt should add enforce a single empty line before a doc comment · Issue #4781 · rust-lang/rustfmt