Skip to content

Cut out a bunch of Result and panictry! boilerplate from libsyntax. #30654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ pub fn get_exprs_from_tts(cx: &mut ExtCtxt,
let mut es = Vec::new();
while p.token != token::Eof {
es.push(cx.expander().fold_expr(panictry!(p.parse_expr())));
if panictry!(p.eat(&token::Comma)){
if p.eat(&token::Comma) {
continue;
}
if p.token != token::Eof {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ fn parse_arguments_to_quote(cx: &ExtCtxt, tts: &[TokenTree])
p.quote_depth += 1;

let cx_expr = panictry!(p.parse_expr());
if !panictry!(p.eat(&token::Comma)) {
if !p.eat(&token::Comma) {
let _ = p.diagnostic().fatal("expected token `,`");
}

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/tt/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ pub fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
_ => {}
}
// check at the beginning and the parser checks after each bump
panictry!(p.check_unknown_macro_variable());
p.check_unknown_macro_variable();
match name {
"item" => match panictry!(p.parse_item()) {
Some(i) => token::NtItem(i),
Expand All @@ -535,7 +535,7 @@ pub fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
// this could be handled like a token, since it is one
"ident" => match p.token {
token::Ident(sn,b) => {
panictry!(p.bump());
p.bump();
token::NtIdent(Box::new(Spanned::<Ident>{node: sn, span: p.span}),b)
}
_ => {
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/tt/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a> ParserAnyMacro<'a> {
fn ensure_complete_parse(&self, allow_semi: bool, context: &str) {
let mut parser = self.parser.borrow_mut();
if allow_semi && parser.token == token::Semi {
panictry!(parser.bump())
parser.bump();
}
if parser.token != token::Eof {
let token_str = parser.this_token_to_string();
Expand Down Expand Up @@ -194,7 +194,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
imported_from,
rhs);
let mut p = Parser::new(cx.parse_sess(), cx.cfg(), Box::new(trncbr));
panictry!(p.check_unknown_macro_variable());
p.check_unknown_macro_variable();
// Let the context choose how to interpret the result.
// Weird, but useful for X-macros.
return Box::new(ParserAnyMacro {
Expand Down
14 changes: 7 additions & 7 deletions src/libsyntax/parse/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'a> Parser<'a> {
return Err(self.fatal("expected outer comment"));
}
attrs.push(attr);
try!(self.bump());
self.bump();
}
_ => break
}
Expand All @@ -57,11 +57,11 @@ impl<'a> Parser<'a> {
let (span, value, mut style) = match self.token {
token::Pound => {
let lo = self.span.lo;
try!(self.bump());
self.bump();

if permit_inner { self.expected_tokens.push(TokenType::Token(token::Not)); }
let style = if self.token == token::Not {
try!(self.bump());
self.bump();
if !permit_inner {
let span = self.span;
self.diagnostic().struct_span_err(span,
Expand Down Expand Up @@ -91,7 +91,7 @@ impl<'a> Parser<'a> {
};

if permit_inner && self.token == token::Semi {
try!(self.bump());
self.bump();
self.span_warn(span, "this inner attribute syntax is deprecated. \
The new syntax is `#![foo]`, with a bang and no semicolon");
style = ast::AttrStyle::Inner;
Expand Down Expand Up @@ -134,7 +134,7 @@ impl<'a> Parser<'a> {
let attr = attr::mk_sugared_doc_attr(attr::mk_attr_id(), str, lo, hi);
if attr.node.style == ast::AttrStyle::Inner {
attrs.push(attr);
try!(self.bump());
self.bump();
} else {
break;
}
Expand All @@ -158,7 +158,7 @@ impl<'a> Parser<'a> {

match nt_meta {
Some(meta) => {
try!(self.bump());
self.bump();
return Ok(meta);
}
None => {}
Expand All @@ -169,7 +169,7 @@ impl<'a> Parser<'a> {
let name = self.id_to_interned_str(ident);
match self.token {
token::Eq => {
try!(self.bump());
self.bump();
let lit = try!(self.parse_lit());
// FIXME #623 Non-string meta items are not serialized correctly;
// just forbid them for now
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub fn tts_to_parser<'a>(sess: &'a ParseSess,
cfg: ast::CrateConfig) -> Parser<'a> {
let trdr = lexer::new_tt_reader(&sess.span_diagnostic, None, None, tts);
let mut p = Parser::new(sess, cfg, Box::new(trdr));
panictry!(p.check_unknown_macro_variable());
p.check_unknown_macro_variable();
p
}

Expand Down
Loading