Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 36dd49a

Browse files
committed
Set macro_rewrite_failure to true on catching panic
1 parent f7cd789 commit 36dd49a

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/macros.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,25 @@ pub(crate) fn rewrite_macro(
209209
shape: Shape,
210210
position: MacroPosition,
211211
) -> Option<String> {
212-
catch_unwind(AssertUnwindSafe(|| {
213-
let should_skip = context
214-
.skip_macro_names
215-
.borrow()
216-
.contains(&context.snippet(mac.node.path.span).to_owned());
217-
if should_skip {
218-
None
219-
} else {
220-
let guard = InsideMacroGuard::inside_macro_context(context);
221-
let result =
222-
rewrite_macro_inner(mac, extra_ident, context, shape, position, guard.is_nested);
223-
if result.is_none() {
212+
let should_skip = context
213+
.skip_macro_names
214+
.borrow()
215+
.contains(&context.snippet(mac.node.path.span).to_owned());
216+
if should_skip {
217+
None
218+
} else {
219+
let guard = InsideMacroGuard::inside_macro_context(context);
220+
let result = catch_unwind(AssertUnwindSafe(|| {
221+
rewrite_macro_inner(mac, extra_ident, context, shape, position, guard.is_nested)
222+
}));
223+
match result {
224+
Err(..) | Ok(None) => {
224225
context.macro_rewrite_failure.replace(true);
226+
None
225227
}
226-
result
228+
Ok(rw) => rw,
227229
}
228-
}))
229-
.ok()?
230+
}
230231
}
231232

232233
fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {

0 commit comments

Comments
 (0)