Nested empty use tree formatting is non-idempotent
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start by reading rustfmt's handling of nested use trees and the regression tests for import formatting; the issue does not name a specific source file or test. Reproduce with use std::sync::{Arc, atomic::{}}; using the shown stable formatting options. Done means one formatting pass produces use std::sync::Arc; with no extra whitespace, and formatting again leaves it unchanged.
Written by the indexing model from the issue text.
Description
Summary
Not quite the same as https://github.com/rust-lang/rustfmt/issues/7140 since that issue is moreso about the interactions with unstable option. Extracted from the comment https://github.com/rust-lang/rustfmt/issues/7140#issuecomment-6098925992.
I tried to format this code:
use std::sync::{Arc, atomic::{}};
Expected behavior
I expected to see this happen: converges to a stable default format in a single pass (idempotent)
use std::sync::Arc;
Actual behavior
Instead, this happened: non-idempontent. Converges after 2 passes:
Pass 1
-use std::sync::{Arc, atomic::{}};
+use std::sync::{ Arc};
(Notice also the extra whitespace)
Pass 2
-use std::sync::{ Arc};
+use std::sync::Arc;
Configuration
Stable default format
rustfmt cli options used (if applicable):
rustfmt +stable foo.rs --config-path=/dev/null --style-edition=2024 --edition=2024
rustfmt configuration file (e.g. rustfmt.toml, if applicable): N/A
Reproduction Steps
See formatting passes above.
Meta
rustfmt --version:
rustfmt 1.10.0-stable (b940084d7e 2026-09-28)
Still broken on nightly.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 26
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from rust-lang/rustfmt
-
A-Unicode C-bug P-low
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
rust-lang/rustfmt#7210 · 5 comments ·
Maintainers usually reply within 1 day
-
A-comments C-bug only-with-option UO-indent_style
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Fix `first_line_width` to be tab-awareMay be free again A pull request for this issue was closed without being merged. OpenA-tabs A-whitespace C-bug SO-hard_tabs
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
C-feature-request P-low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-lang/rustfmt#7114 · 2 reactions ·
Maintainers usually reply within 1 day
-
Dependency DashboardOpenA-CI
Difficulty 1/5 Under an hour Newbie friendliness 1/100
Maintainers usually reply within 1 day
All issues in rust-lang/rustfmt
Similar issues
-
nn::linear: weight initialization depends on `bias` because the bias is created before the weightPossibly taken @monfortema claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
LaurentMazare/tch-rs#1067 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
FavioVazquez/mollify#62 ·
-
C-enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
obi1kenobi/cargo-semver-checks#1785 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
fendouai/awesome-deepseek-harness#125 ·
Maintainers usually reply within 4 days