diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2015-10-27 22:20:01 -0700 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2015-10-28 14:11:31 -0700 |
| commit | e7d3ae606ed496144554dae499b69207da3b09c5 (patch) | |
| tree | cd68b8303226e9a6b1b30c70aa7d7fa3597cf326 /src/libsyntax/parse | |
| parent | 56ba8feed694f46f28d9e65e132e1b62cc18e0b4 (diff) | |
| download | rust-e7d3ae606ed496144554dae499b69207da3b09c5.tar.gz rust-e7d3ae606ed496144554dae499b69207da3b09c5.zip | |
Make quote plugin use parsing functions which explicitly panic.
Rename parse_* to parse_*_panic, and add parse_attribute_panic.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 16 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 7b96135f1c3..5df2478d487 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -51,7 +51,7 @@ impl<'a> Parser<'a> { /// /// If permit_inner is true, then a leading `!` indicates an inner /// attribute - fn parse_attribute(&mut self, permit_inner: bool) -> PResult<ast::Attribute> { + pub fn parse_attribute(&mut self, permit_inner: bool) -> PResult<ast::Attribute> { debug!("parse_attributes: permit_inner={:?} self.token={:?}", permit_inner, self.token); let (span, value, mut style) = match self.token { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d71ea4d105b..570934a5bff 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -360,30 +360,34 @@ impl<'a> Parser<'a> { // Panicing fns (for now!) // These functions are used by the quote_*!() syntax extensions, but shouldn't // be used otherwise. - pub fn parse_expr(&mut self) -> P<Expr> { + pub fn parse_expr_panic(&mut self) -> P<Expr> { panictry!(self.parse_expr_nopanic()) } - pub fn parse_item(&mut self) -> Option<P<Item>> { + pub fn parse_item_panic(&mut self) -> Option<P<Item>> { panictry!(self.parse_item_nopanic()) } - pub fn parse_pat(&mut self) -> P<Pat> { + pub fn parse_pat_panic(&mut self) -> P<Pat> { panictry!(self.parse_pat_nopanic()) } - pub fn parse_arm(&mut self) -> Arm { + pub fn parse_arm_panic(&mut self) -> Arm { panictry!(self.parse_arm_nopanic()) } - pub fn parse_ty(&mut self) -> P<Ty> { + pub fn parse_ty_panic(&mut self) -> P<Ty> { panictry!(self.parse_ty_nopanic()) } - pub fn parse_stmt(&mut self) -> Option<P<Stmt>> { + pub fn parse_stmt_panic(&mut self) -> Option<P<Stmt>> { panictry!(self.parse_stmt_nopanic()) } + pub fn parse_attribute_panic(&mut self, permit_inner: bool) -> ast::Attribute { + panictry!(self.parse_attribute(permit_inner)) + } + /// Convert a token to a string using self's reader pub fn token_to_string(token: &token::Token) -> String { pprust::token_to_string(token) |
