`reorder_imports=false` conflicts with `imports_indent="Visual"`
Open
Nobody has claimed this yet.
I-poor-formatting
only-with-option
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
When using both imports_indent="Visual" and reorder_imports=false the alignments of all subsequent lines within the block are off by 4 spaces.
To Reproduce
source:
// rustfmt-imports_indent: Visual
// rustfmt-reorder_imports: false
use module::{
submodule_A::{Type_A1, Type_A2},
submodule_B::{Type_B1, Type_B2},
};
target:
// rustfmt-imports_indent: Visual
// rustfmt-reorder_imports: false
use module::{submodule_A::{Type_A1, Type_A2},
submodule_B::{Type_B1, Type_B2}};
Expected behavior
// rustfmt-imports_indent: Visual
// rustfmt-reorder_imports: false
use module::{submodule_A::{Type_A1, Type_A2},
submodule_B::{Type_B1, Type_B2}};
Note that:
- The correct thing happens when either
imports_indent="Visual"orreorder_imports=falseis set, but not when they are both set simultaneously. - No reordering of modules needs to actually happen (or be prevented from happening) for this to occur.
Meta
- rustfmt version: 94035f9148d31d3f714d9c649cf2de0f0edb4f46 (HEAD -> master)
refs #3360
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied rustfmt reproduction with imports_indent="Visual" and reorder_imports=false, comparing the generated alignment with the expected output. Trace the formatting path for nested imports and verify that subsequent lines use the expected indentation when both options are enabled; done means the example formats exactly as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100