perpetually increasing indentation in nested macro
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Start by reproducing the issue with the nested macro_rules! example in the issue body, using the supplied hard_tabs = true configuration; the report says it also occurs without that setting. Compare the output across repeated runs and trace how rustfmt formats nested declarative macros. Done means formatting the example repeatedly no longer increases indentation and preserves the expected layout.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Multiple executions keep adding more and more levels of indentation in a nested declarative macro.
I tried to format this code:
macro_rules! exclude {
($x:ident, [$($y:ident),* $(,)?] $(,)?) => {
macro_rules! exclude_inner {
($x) => {};
($z:ident) => { $z , };
}
};
}
Expected behavior
I expected to see this happen: the code is left as-is, since it's already formatted properly.
Actual behavior
Instead, this happened: the nested macro gets another level of indentation every time the formatter is ran.
First execution:
macro_rules! exclude {
($x:ident, [$($y:ident),* $(,)?] $(,)?) => {
macro_rules! exclude_inner {
($x) => {};
($z:ident) => { $z , };
}
};
}
Second execution:
macro_rules! exclude {
($x:ident, [$($y:ident),* $(,)?] $(,)?) => {
macro_rules! exclude_inner {
($x) => {};
($z:ident) => { $z , };
}
};
}
third:
macro_rules! exclude {
($x:ident, [$($y:ident),* $(,)?] $(,)?) => {
macro_rules! exclude_inner {
($x) => {};
($z:ident) => { $z , };
}
};
}
After many tries, this seems to be the maximum it'll go.
macro_rules! exclude {
($x:ident, [$($y:ident),* $(,)?] $(,)?) => {
macro_rules! exclude_inner {
($x) => {};
($z:ident) => { $z , };
}
};
}
Configuration
rustfmt configuration file (e.g. rustfmt.toml, if applicable):
hard_tabs = true
(but the bug happens without that too).
Reproduction Steps
No additional steps beyond running the formatter on the code provided earlier.
Meta
rustfmt --version:
rustfmt 1.9.0-stable (ac68faa20c 2026-05-25)
and
rustfmt --version:
rustfmt 1.10.0-nightly (67eda617e6 2026-09-10)
- Ngôn ngữ chính
- Rust
- Star
- 7.1k
- Fork
- 1.2k
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-lang/rustfmt
-
A-config C-bug SO-print-config
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A-Unicode C-bug P-low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
rust-lang/rustfmt#7210 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A-imports C-bug E-hard I-non-idempotency X-impacts-stable-default-format
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rust-lang/rustfmt#7173 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A-comments C-bug only-with-option UO-indent_style
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix `first_line_width` to be tab-awareCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởA-tabs A-whitespace C-bug SO-hard_tabs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rust-lang/rustfmt
Issue tương tự
-
bug P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows microphone listing treats words in a device name as DirectShow labelsCó thể đã có người làm @Sujal-chaudhary đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
clipy-recorder/clipy#447 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
nightly-cleanup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
max-sixty/worktrunk#4939 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Flaky Test] tests::signer::v0::miner_recovers_when_broadcast_block_delay_across_tenures_occursĐang mởflaky
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
stacks-network/stacks-core#7918 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày