Set macro_rewrite_failure to true on catching panic
@@ -209,7 +209,6 @@ pub(crate) fn rewrite_macro(
shape: Shape,
position: MacroPosition,
) -> Option<String> {
- catch_unwind(AssertUnwindSafe(|| {
let should_skip = context
.skip_macro_names
.borrow()
@@ -218,15 +217,17 @@ pub(crate) fn rewrite_macro(
None
} else {
let guard = InsideMacroGuard::inside_macro_context(context);
- let result =
- rewrite_macro_inner(mac, extra_ident, context, shape, position, guard.is_nested);
- if result.is_none() {
+ let result = catch_unwind(AssertUnwindSafe(|| {
+ rewrite_macro_inner(mac, extra_ident, context, shape, position, guard.is_nested)
+ }));
+ match result {
+ Err(..) | Ok(None) => {
context.macro_rewrite_failure.replace(true);
+ None
+ }
+ Ok(rw) => rw,
}
- result
}
- }))
- .ok()?
}
fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
