about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2021-12-29 19:18:34 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2021-12-29 19:18:34 +0300
commitf5cfc0504e30b2e87dc9405fc3aeaee8e2fa6b08 (patch)
tree3fb301c710f81ca20392a7a2197b5ca783f73c4a
parent8234a85d158ec83581d970a4a669f97b07c56c2f (diff)
downloadrust-f5cfc0504e30b2e87dc9405fc3aeaee8e2fa6b08.tar.gz
rust-f5cfc0504e30b2e87dc9405fc3aeaee8e2fa6b08.zip
rename
-rw-r--r--crates/parser/src/grammar.rs4
-rw-r--r--crates/parser/src/grammar/expressions.rs35
2 files changed, 19 insertions, 20 deletions
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs
index 234e584eeb7..b704242065c 100644
--- a/crates/parser/src/grammar.rs
+++ b/crates/parser/src/grammar.rs
@@ -59,7 +59,7 @@ pub(crate) mod entry {
         }
 
         pub(crate) fn stmt(p: &mut Parser) {
-            expressions::stmt(p, expressions::StmtWithSemi::No);
+            expressions::stmt(p, expressions::Semicolon::Forbidden);
         }
 
         pub(crate) fn pat(p: &mut Parser) {
@@ -103,7 +103,7 @@ pub(crate) mod entry {
                     continue;
                 }
 
-                expressions::stmt(p, expressions::StmtWithSemi::Optional);
+                expressions::stmt(p, expressions::Semicolon::Optional);
             }
 
             m.complete(p, MACRO_STMTS);
diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs
index 3238b6e9f44..c585fdb0967 100644
--- a/crates/parser/src/grammar/expressions.rs
+++ b/crates/parser/src/grammar/expressions.rs
@@ -6,10 +6,10 @@ pub(crate) use self::atom::{block_expr, match_arm_list};
 pub(super) use self::atom::{literal, LITERAL_FIRST};
 
 #[derive(PartialEq, Eq)]
-pub(super) enum StmtWithSemi {
-    Yes,
-    No,
+pub(super) enum Semicolon {
+    Required,
     Optional,
+    Forbidden,
 }
 
 const EXPR_FIRST: TokenSet = LHS_FIRST;
@@ -29,7 +29,7 @@ fn expr_no_struct(p: &mut Parser) {
     expr_bp(p, None, r, 1);
 }
 
-pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
+pub(super) fn stmt(p: &mut Parser, semicolon: Semicolon) {
     let m = p.start();
     // test attr_on_expr_stmt
     // fn foo() {
@@ -41,7 +41,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
     attributes::outer_attrs(p);
 
     if p.at(T![let]) {
-        let_stmt(p, m, with_semi);
+        let_stmt(p, m, semicolon);
         return;
     }
 
@@ -53,7 +53,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
     };
 
     if let Some((cm, blocklike)) = expr_stmt(p, Some(m)) {
-        if !(p.at(T!['}']) || (with_semi != StmtWithSemi::Yes && p.at(EOF))) {
+        if !(p.at(T!['}']) || (semicolon != Semicolon::Required && p.at(EOF))) {
             // test no_semi_after_block
             // fn foo() {
             //     if true {}
@@ -69,27 +69,26 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
             //     test!{}
             // }
             let m = cm.precede(p);
-            match with_semi {
-                StmtWithSemi::No => (),
-                StmtWithSemi::Optional => {
-                    p.eat(T![;]);
-                }
-                StmtWithSemi::Yes => {
+            match semicolon {
+                Semicolon::Required => {
                     if blocklike.is_block() {
                         p.eat(T![;]);
                     } else {
                         p.expect(T![;]);
                     }
                 }
+                Semicolon::Optional => {
+                    p.eat(T![;]);
+                }
+                Semicolon::Forbidden => (),
             }
-
             m.complete(p, EXPR_STMT);
         }
     }
 
     // test let_stmt
     // fn f() { let x: i32 = 92; }
-    fn let_stmt(p: &mut Parser, m: Marker, with_semi: StmtWithSemi) {
+    fn let_stmt(p: &mut Parser, m: Marker, with_semi: Semicolon) {
         p.bump(T![let]);
         patterns::pattern(p);
         if p.at(T![:]) {
@@ -114,11 +113,11 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
         }
 
         match with_semi {
-            StmtWithSemi::No => (),
-            StmtWithSemi::Optional => {
+            Semicolon::Forbidden => (),
+            Semicolon::Optional => {
                 p.eat(T![;]);
             }
-            StmtWithSemi::Yes => {
+            Semicolon::Required => {
                 p.expect(T![;]);
             }
         }
@@ -150,7 +149,7 @@ pub(super) fn expr_block_contents(p: &mut Parser) {
             continue;
         }
 
-        stmt(p, StmtWithSemi::Yes);
+        stmt(p, Semicolon::Required);
     }
 }