Skip to content

rustfmt inserts newline between comment and use when both reorder_imports and reorder_imports_in_group is set to true #1789

Closed

Description

@topecongiro

rustfmt.toml

reorder_imports = true
reorder_imports_in_group = true

input

// cmp
use std::cmp;
use std::cmp::{max, min, Ordering};

output

// cmp

use std::cmp;
use std::cmp::{max, min, Ordering};

Activity

  1. added
    A-comments
    only-with-option
    I-poor-formatting
    on Jul 14, 2017
  2. topecongiro commented on Jul 14, 2017

    @topecongiro
    ContributorAuthor

    Should reorder_imports_in_group regard comment as a separator?
    For example, when given the following snippet,

    use std::cmp::{max, min, Ordering};
    // cmp
    use std::cmp;

    which output should we use?

    1. Consider comment as a part of the following use and move the comment with it
    // cmp
    use std::cmp;
    use std::cmp::{max, min, Ordering};
    1. Consider comment as a separator
    use std::cmp::{max, min, Ordering};
    // cmp
    use std::cmp;
  3. topecongiro commented on Jul 14, 2017

    @topecongiro
    ContributorAuthor

    Closing since this was a dup of #1373.

  4. added
    S-duplicate
    on Jul 14, 2017
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-commentsI-poor-formattingP-highS-duplicateonly-with-option

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions