Skip to content

imports_granularity = "Module" merges top-level modules into a single use statement #6191

Open
@mnkhouri

Description

@mnkhouri

Documented behavior

The current docs for imports_granularity = "Module" say this:

Merge imports from the same module into a single use statement. Conversely, imports from different modules are split into separate statements.

The current example in docs looks like this:

use foo::b::{f, g};
use foo::d::e;
use foo::{a, b, c};
use qux::{h, i};

Current formatting of "top-level" modules

For imports of a entire modules, when the path only has a single item (no submodules), the current output when using imports_granularity = "Module" is to format like this:

use {library1, library2 as lib2, library3};

Suggested formatting of "top-level" modules

The docs say "imports from different modules are split into separate statements". My reading of the docs and my intuition would say the formatting should instead look like this:

use library1;
use library2 as lib2;
use library3;

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-imports`use` syntaxonly-with-optionrequires a non-default option value to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions