mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 03:03:21 +00:00
Return original snippet when macro contains invalid syntax
This commit is contained in:
parent
7c8432f05b
commit
e3eec44690
@ -113,14 +113,14 @@ pub fn rewrite_macro(mac: &ast::Mac,
|
||||
Ok(expr) => {
|
||||
// Recovered errors.
|
||||
if context.parse_session.span_diagnostic.has_errors() {
|
||||
return None;
|
||||
return Some(context.snippet(mac.span));
|
||||
}
|
||||
|
||||
expr
|
||||
}
|
||||
Err(mut e) => {
|
||||
e.cancel();
|
||||
return None;
|
||||
return Some(context.snippet(mac.span));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -78,6 +78,11 @@ fn main() {
|
||||
// comment
|
||||
not function like
|
||||
);
|
||||
|
||||
// #1577
|
||||
let json = json!({
|
||||
"foo": "bar",
|
||||
});
|
||||
}
|
||||
|
||||
impl X {
|
||||
|
@ -83,6 +83,11 @@ fn main() {
|
||||
// comment
|
||||
not function like
|
||||
);
|
||||
|
||||
// #1577
|
||||
let json = json!({
|
||||
"foo": "bar",
|
||||
});
|
||||
}
|
||||
|
||||
impl X {
|
||||
|
Loading…
Reference in New Issue
Block a user