Return original snippet when macro contains invalid syntax
This commit is contained in:
parent
7c8432f05b
commit
e3eec44690
3 changed files with 12 additions and 2 deletions
|
@ -113,14 +113,14 @@ pub fn rewrite_macro(mac: &ast::Mac,
|
||||||
Ok(expr) => {
|
Ok(expr) => {
|
||||||
// Recovered errors.
|
// Recovered errors.
|
||||||
if context.parse_session.span_diagnostic.has_errors() {
|
if context.parse_session.span_diagnostic.has_errors() {
|
||||||
return None;
|
return Some(context.snippet(mac.span));
|
||||||
}
|
}
|
||||||
|
|
||||||
expr
|
expr
|
||||||
}
|
}
|
||||||
Err(mut e) => {
|
Err(mut e) => {
|
||||||
e.cancel();
|
e.cancel();
|
||||||
return None;
|
return Some(context.snippet(mac.span));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,11 @@ fn main() {
|
||||||
// comment
|
// comment
|
||||||
not function like
|
not function like
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// #1577
|
||||||
|
let json = json!({
|
||||||
|
"foo": "bar",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
impl X {
|
impl X {
|
||||||
|
|
|
@ -83,6 +83,11 @@ fn main() {
|
||||||
// comment
|
// comment
|
||||||
not function like
|
not function like
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// #1577
|
||||||
|
let json = json!({
|
||||||
|
"foo": "bar",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
impl X {
|
impl X {
|
||||||
|
|
Loading…
Reference in a new issue