Set macro_rewrite_failure to true on catching panic
This commit is contained in:
parent
f7cd789ebc
commit
36dd49ae5f
@ -209,24 +209,25 @@ pub(crate) fn rewrite_macro(
|
|||||||
shape: Shape,
|
shape: Shape,
|
||||||
position: MacroPosition,
|
position: MacroPosition,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
catch_unwind(AssertUnwindSafe(|| {
|
let should_skip = context
|
||||||
let should_skip = context
|
.skip_macro_names
|
||||||
.skip_macro_names
|
.borrow()
|
||||||
.borrow()
|
.contains(&context.snippet(mac.node.path.span).to_owned());
|
||||||
.contains(&context.snippet(mac.node.path.span).to_owned());
|
if should_skip {
|
||||||
if should_skip {
|
None
|
||||||
None
|
} else {
|
||||||
} else {
|
let guard = InsideMacroGuard::inside_macro_context(context);
|
||||||
let guard = InsideMacroGuard::inside_macro_context(context);
|
let result = catch_unwind(AssertUnwindSafe(|| {
|
||||||
let result =
|
rewrite_macro_inner(mac, extra_ident, context, shape, position, guard.is_nested)
|
||||||
rewrite_macro_inner(mac, extra_ident, context, shape, position, guard.is_nested);
|
}));
|
||||||
if result.is_none() {
|
match result {
|
||||||
|
Err(..) | Ok(None) => {
|
||||||
context.macro_rewrite_failure.replace(true);
|
context.macro_rewrite_failure.replace(true);
|
||||||
|
None
|
||||||
}
|
}
|
||||||
result
|
Ok(rw) => rw,
|
||||||
}
|
}
|
||||||
}))
|
}
|
||||||
.ok()?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
|
fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user