rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

Use the same shape to rewrite import when reordering them or not

Open ytmimi opened this issue 3 years ago • 2 comments

Fixes #4794

The code paths for formatting imports diverge based on the value of reorder_imports. Each code path used a slightly different shape when rewriting the imports which lead to issues when reorder_imports = false and imports_indent = Visual.

Now the code path that rewrites imports without reordering uses the same shape as the path that also reorders imports.

ytmimi avatar Apr 11 '22 14:04 ytmimi

I think this is good, but could you add some test cases that have imports nested a few levels (e.g. imports within some in-line mod or other item)

calebcartwright avatar May 30 '22 21:05 calebcartwright

could you add some test cases that have imports nested a few levels (e.g. imports within some in-line mod or other item)

@calebcartwright I added the test cases you were looking for. CI is still running right now, but assuming it passes I think we're good to go here!

ytmimi avatar Jun 22 '22 03:06 ytmimi