@@ -6,10 +6,10 @@ pub(crate) use self::atom::{block_expr, match_arm_list};
6
6
pub ( super ) use self :: atom:: { literal, LITERAL_FIRST } ;
7
7
8
8
#[ derive( PartialEq , Eq ) ]
9
- pub ( super ) enum StmtWithSemi {
10
- Yes ,
11
- No ,
9
+ pub ( super ) enum Semicolon {
10
+ Required ,
12
11
Optional ,
12
+ Forbidden ,
13
13
}
14
14
15
15
const EXPR_FIRST : TokenSet = LHS_FIRST ;
@@ -29,7 +29,7 @@ fn expr_no_struct(p: &mut Parser) {
29
29
expr_bp ( p, None , r, 1 ) ;
30
30
}
31
31
32
- pub ( super ) fn stmt ( p : & mut Parser , with_semi : StmtWithSemi ) {
32
+ pub ( super ) fn stmt ( p : & mut Parser , semicolon : Semicolon ) {
33
33
let m = p. start ( ) ;
34
34
// test attr_on_expr_stmt
35
35
// fn foo() {
@@ -41,7 +41,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
41
41
attributes:: outer_attrs ( p) ;
42
42
43
43
if p. at ( T ! [ let ] ) {
44
- let_stmt ( p, m, with_semi ) ;
44
+ let_stmt ( p, m, semicolon ) ;
45
45
return ;
46
46
}
47
47
@@ -53,7 +53,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
53
53
} ;
54
54
55
55
if let Some ( ( cm, blocklike) ) = expr_stmt ( p, Some ( m) ) {
56
- if !( p. at ( T ! [ '}' ] ) || ( with_semi != StmtWithSemi :: Yes && p. at ( EOF ) ) ) {
56
+ if !( p. at ( T ! [ '}' ] ) || ( semicolon != Semicolon :: Required && p. at ( EOF ) ) ) {
57
57
// test no_semi_after_block
58
58
// fn foo() {
59
59
// if true {}
@@ -69,27 +69,26 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
69
69
// test!{}
70
70
// }
71
71
let m = cm. precede ( p) ;
72
- match with_semi {
73
- StmtWithSemi :: No => ( ) ,
74
- StmtWithSemi :: Optional => {
75
- p. eat ( T ! [ ; ] ) ;
76
- }
77
- StmtWithSemi :: Yes => {
72
+ match semicolon {
73
+ Semicolon :: Required => {
78
74
if blocklike. is_block ( ) {
79
75
p. eat ( T ! [ ; ] ) ;
80
76
} else {
81
77
p. expect ( T ! [ ; ] ) ;
82
78
}
83
79
}
80
+ Semicolon :: Optional => {
81
+ p. eat ( T ! [ ; ] ) ;
82
+ }
83
+ Semicolon :: Forbidden => ( ) ,
84
84
}
85
-
86
85
m. complete ( p, EXPR_STMT ) ;
87
86
}
88
87
}
89
88
90
89
// test let_stmt
91
90
// fn f() { let x: i32 = 92; }
92
- fn let_stmt ( p : & mut Parser , m : Marker , with_semi : StmtWithSemi ) {
91
+ fn let_stmt ( p : & mut Parser , m : Marker , with_semi : Semicolon ) {
93
92
p. bump ( T ! [ let ] ) ;
94
93
patterns:: pattern ( p) ;
95
94
if p. at ( T ! [ : ] ) {
@@ -114,11 +113,11 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
114
113
}
115
114
116
115
match with_semi {
117
- StmtWithSemi :: No => ( ) ,
118
- StmtWithSemi :: Optional => {
116
+ Semicolon :: Forbidden => ( ) ,
117
+ Semicolon :: Optional => {
119
118
p. eat ( T ! [ ; ] ) ;
120
119
}
121
- StmtWithSemi :: Yes => {
120
+ Semicolon :: Required => {
122
121
p. expect ( T ! [ ; ] ) ;
123
122
}
124
123
}
@@ -150,7 +149,7 @@ pub(super) fn expr_block_contents(p: &mut Parser) {
150
149
continue ;
151
150
}
152
151
153
- stmt ( p, StmtWithSemi :: Yes ) ;
152
+ stmt ( p, Semicolon :: Required ) ;
154
153
}
155
154
}
156
155
0 commit comments