-
Notifications
You must be signed in to change notification settings - Fork 975
Open
Labels
A-macrosArea: macros (procedural macros, macro_rules! macros, etc.)Area: macros (procedural macros, macro_rules! macros, etc.)C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEE-help-wantedCall for participation: help is requested to fix this issueCall for participation: help is requested to fix this issue
Description
Input
macro_rules! outer {
($d:tt) => {
macro_rules! inner {
($d s:expr) => {
println!("{}", $d s);
}
}
};
}
outer!($);
fn main() {
inner!("hi");
}Output
Note that the body and trailing closing braces of the nested macro_rules block is indented. With further invocations of rustfmt, this block is continuously indented to the next level.
Removing the usage of the inner macro_rules's $s in the println! usage causes the formatting to behave as expected.
macro_rules! outer {
($d:tt) => {
macro_rules! inner {
($d s:expr) => {
println!("{}", $d s);
}
}
};
}
outer!($);
fn main() {
inner!("hi");
}Expected output
The input should likely remain unchanged.
Meta
- rustfmt version: 1.4.27-nightly (2020-11-16 580d826), as used on Rust Playground
- From where did you install rustfmt?: Rust Playground
Ten0 and holderman1206
Metadata
Metadata
Assignees
Labels
A-macrosArea: macros (procedural macros, macro_rules! macros, etc.)Area: macros (procedural macros, macro_rules! macros, etc.)C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEE-help-wantedCall for participation: help is requested to fix this issueCall for participation: help is requested to fix this issue