diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2015-10-23 18:33:19 -0700 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2015-10-27 20:09:10 -0700 |
| commit | 1dd87dcfeaec795f67ddfeca58e13d9eed909684 (patch) | |
| tree | 1d60e670292b14026e2ab0083198cad0d46fe823 /src/libsyntax/ext/tt | |
| parent | f7172490f8f5c3a9d924a1abdc5123b64c18f4ea (diff) | |
| download | rust-1dd87dcfeaec795f67ddfeca58e13d9eed909684.tar.gz rust-1dd87dcfeaec795f67ddfeca58e13d9eed909684.zip | |
Don't use panicking helpers in Parser.
Diffstat (limited to 'src/libsyntax/ext/tt')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 8dec9ae1e98..5cb5b95e2cb 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -503,18 +503,18 @@ pub fn parse_nt(p: &mut Parser, sp: Span, name: &str) -> Nonterminal { // check at the beginning and the parser checks after each bump panictry!(p.check_unknown_macro_variable()); match name { - "item" => match p.parse_item() { + "item" => match panictry!(p.parse_item_nopanic()) { Some(i) => token::NtItem(i), None => panic!(p.fatal("expected an item keyword")) }, "block" => token::NtBlock(panictry!(p.parse_block())), - "stmt" => match p.parse_stmt() { + "stmt" => match panictry!(p.parse_stmt_nopanic()) { Some(s) => token::NtStmt(s), None => panic!(p.fatal("expected a statement")) }, - "pat" => token::NtPat(p.parse_pat()), - "expr" => token::NtExpr(p.parse_expr()), - "ty" => token::NtTy(p.parse_ty()), + "pat" => token::NtPat(panictry!(p.parse_pat_nopanic())), + "expr" => token::NtExpr(panictry!(p.parse_expr_nopanic())), + "ty" => token::NtTy(panictry!(p.parse_ty_nopanic())), // this could be handled like a token, since it is one "ident" => match p.token { token::Ident(sn,b) => { panictry!(p.bump()); token::NtIdent(Box::new(sn),b) } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index cce4450b299..a98c001dc0e 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -66,18 +66,18 @@ impl<'a> ParserAnyMacro<'a> { impl<'a> MacResult for ParserAnyMacro<'a> { fn make_expr(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Expr>> { - let ret = self.parser.borrow_mut().parse_expr(); + let ret = panictry!(self.parser.borrow_mut().parse_expr_nopanic()); self.ensure_complete_parse(true); Some(ret) } fn make_pat(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Pat>> { - let ret = self.parser.borrow_mut().parse_pat(); + let ret = panictry!(self.parser.borrow_mut().parse_pat_nopanic()); self.ensure_complete_parse(false); Some(ret) } fn make_items(self: Box<ParserAnyMacro<'a>>) -> Option<SmallVector<P<ast::Item>>> { let mut ret = SmallVector::zero(); - while let Some(item) = self.parser.borrow_mut().parse_item() { + while let Some(item) = panictry!(self.parser.borrow_mut().parse_item_nopanic()) { ret.push(item); } self.ensure_complete_parse(false); @@ -119,7 +119,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> { } fn make_ty(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Ty>> { - let ret = self.parser.borrow_mut().parse_ty(); + let ret = panictry!(self.parser.borrow_mut().parse_ty_nopanic()); self.ensure_complete_parse(true); Some(ret) } |
