Skip to content

Commit 339fa20

Browse files
committed
Veto converting delimiters inside nested macro
1 parent 975b375 commit 339fa20

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/macros.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub fn rewrite_macro(
168168
position: MacroPosition,
169169
) -> Option<String> {
170170
let guard = InsideMacroGuard::inside_macro_context(context);
171-
let result = rewrite_macro_inner(mac, extra_ident, context, shape, position);
171+
let result = rewrite_macro_inner(mac, extra_ident, context, shape, position, guard.is_nested);
172172
if result.is_none() {
173173
context.macro_rewrite_failure.replace(true);
174174
}
@@ -181,6 +181,7 @@ pub fn rewrite_macro_inner(
181181
context: &RewriteContext,
182182
shape: Shape,
183183
position: MacroPosition,
184+
is_nested_macro: bool,
184185
) -> Option<String> {
185186
if context.config.use_try_shorthand() {
186187
if let Some(expr) = convert_try_mac(mac, context) {
@@ -193,7 +194,7 @@ pub fn rewrite_macro_inner(
193194

194195
let macro_name = rewrite_macro_name(context, &mac.node.path, extra_ident);
195196

196-
let style = if FORCED_BRACKET_MACROS.contains(&&macro_name[..]) {
197+
let style = if FORCED_BRACKET_MACROS.contains(&&macro_name[..]) && !is_nested_macro {
197198
DelimToken::Bracket
198199
} else {
199200
original_style
@@ -326,7 +327,7 @@ pub fn rewrite_macro_inner(
326327
} else {
327328
Some(SeparatorTactic::Never)
328329
};
329-
if FORCED_BRACKET_MACROS.contains(macro_name) {
330+
if FORCED_BRACKET_MACROS.contains(macro_name) && !is_nested_macro {
330331
context.inside_macro.replace(false);
331332
if context.use_block_indent() {
332333
force_trailing_comma = Some(SeparatorTactic::Vertical);

0 commit comments

Comments
 (0)