From 749907d330e5487eb7997479e2aba4ac2c2e3494 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 8 Sep 2018 10:38:53 +0300 Subject: simplify --- crates/libsyntax2/src/grammar/expressions/atom.rs | 10 +++++----- crates/libsyntax2/src/grammar/expressions/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/libsyntax2/src/grammar/expressions') diff --git a/crates/libsyntax2/src/grammar/expressions/atom.rs b/crates/libsyntax2/src/grammar/expressions/atom.rs index 1488e12a4..fdb4718ba 100644 --- a/crates/libsyntax2/src/grammar/expressions/atom.rs +++ b/crates/libsyntax2/src/grammar/expressions/atom.rs @@ -18,7 +18,7 @@ pub(crate) const LITERAL_FIRST: TokenSet = STRING, RAW_STRING, BYTE_STRING, RAW_BYTE_STRING]; pub(crate) fn literal(p: &mut Parser) -> Option { - if !LITERAL_FIRST.contains(p.current()) { + if !p.at_ts(LITERAL_FIRST) { return None; } let m = p.start(); @@ -108,7 +108,7 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker { let mut saw_expr = false; while !p.at(EOF) && !p.at(R_PAREN) { saw_expr = true; - if !EXPR_FIRST.contains(p.current()) { + if !p.at_ts(EXPR_FIRST) { p.error("expected expression"); break; } @@ -147,7 +147,7 @@ fn array_expr(p: &mut Parser) -> CompletedMarker { if p.at(R_BRACK) { break; } - if !EXPR_FIRST.contains(p.current()) { + if !p.at_ts(EXPR_FIRST) { p.error("expected expression"); break; } @@ -360,7 +360,7 @@ fn return_expr(p: &mut Parser) -> CompletedMarker { assert!(p.at(RETURN_KW)); let m = p.start(); p.bump(); - if EXPR_FIRST.contains(p.current()) { + if p.at_ts(EXPR_FIRST) { expr(p); } m.complete(p, RETURN_EXPR) @@ -395,7 +395,7 @@ fn break_expr(p: &mut Parser) -> CompletedMarker { let m = p.start(); p.bump(); p.eat(LIFETIME); - if EXPR_FIRST.contains(p.current()) { + if p.at_ts(EXPR_FIRST) { expr(p); } m.complete(p, BREAK_EXPR) diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs index f7b9f7086..d5ee91ad8 100644 --- a/crates/libsyntax2/src/grammar/expressions/mod.rs +++ b/crates/libsyntax2/src/grammar/expressions/mod.rs @@ -236,7 +236,7 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option { DOTDOT => { m = p.start(); p.bump(); - if EXPR_FIRST.contains(p.current()) { + if p.at_ts(EXPR_FIRST) { expr_bp(p, r, 2); } return Some(m.complete(p, RANGE_EXPR)); @@ -376,7 +376,7 @@ fn arg_list(p: &mut Parser) { let m = p.start(); p.bump(); while !p.at(R_PAREN) && !p.at(EOF) { - if !EXPR_FIRST.contains(p.current()) { + if !p.at_ts(EXPR_FIRST) { p.error("expected expression"); break; } -- cgit v1.2.3