Skip to content

Imports are not formatted when long import lines are present #4746

Open
@ciphergoth

Description

@ciphergoth

On some inputs containing long lines, rustfmt makes no changes, either to those lines or any other imports. Using shorter identifiers fixes the problem.

To Reproduce

Run rustup run nightly rustfmt --verbose --config imports_granularity=Crate --emit stdout on this input file:

use foo::bar;
use foo::{quuz, baz};
use abaadfsasdfdsfdfas::aasdffjsioejr::abc::sdsdf::sdfsdfsdf::sdfsdfdsf::{
    asdfasdefasdasdfsdfdfasdf::asdfasdasedfafasdfasdf,
};

The input file will be returned unchanged.

Expected behavior

Delete the final s from the initial abaadfsasdfdsfdfas and the correct behavior is seen; the output is

use abaadfsasdfdsfdfa::aasdffjsioejr::abc::sdsdf::sdfsdfsdf::sdfsdfdsf::asdfasdefasdasdfsdfdfasdf::asdfasdasedfafasdfasdf;
use foo::{bar, baz, quuz};

I can reproduce the same behavior with merge_imports=true on stable.

Meta

  • rustfmt version: rustup run nightly rustfmt --version returns rustfmt 1.4.36-nightly (7de6968 2021-02-07).
  • From where did you install rustfmt?: rustup
  • How do you run rustfmt: rustfmt

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