Skip to content

Commit a8c27c7

Browse files
committed
macros: Cancel DiagnosticBuilder when not emitting error
The error handling in libsyntax changed to use a `DiagnosticBuilder` type in the `Err` variant of `PResult`. This type has `emit()` and `cancel()` methods. Once created, errors must be emitted or canceled; if not, the `Drop` impl on `DiagnosticBuilder` will panic. The first syntex_syntax release to include this change was v0.25.0. The bump from v0.23.0 to v0.29.1 in #847 did not add any `cancel()` calls, even though at least one was required. There may be others not caught in this commit.
1 parent c59d96a commit a8c27c7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/macros.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ pub fn rewrite_macro(mac: &ast::Mac,
8282
loop {
8383
expr_vec.push(match parser.parse_expr() {
8484
Ok(expr) => expr,
85-
Err(..) => return None,
85+
Err(mut e) => {
86+
e.cancel();
87+
return None;
88+
}
8689
});
8790

8891
match parser.token {

0 commit comments

Comments
 (0)