File tree Expand file tree Collapse file tree 4 files changed +15
-20
lines changed
hir_def/src/macro_expansion_tests/mbe Expand file tree Collapse file tree 4 files changed +15
-20
lines changed Original file line number Diff line number Diff line change @@ -85,17 +85,21 @@ fn stmt_boundaries() {
85
85
check (
86
86
r#"
87
87
macro_rules! m {
88
- ($($s:stmt)*) => (stringify!($($s |)*))
88
+ ($($s:stmt)*) => (stringify!($($s |)*); )
89
89
}
90
- // +errors
91
90
m!(;;92;let x = 92; loop {};);
92
91
"# ,
93
92
expect ! [ [ r#"
94
93
macro_rules! m {
95
- ($($s:stmt)*) => (stringify!($($s |)*))
94
+ ($($s:stmt)*) => (stringify!($($s |)*); )
96
95
}
97
- /* error: expected Stmt *//* parse error: expected SEMICOLON */
98
- stringify!()
96
+ stringify!(;
97
+ |;
98
+ |92|;
99
+ |let x = 92|;
100
+ |loop {}
101
+ |;
102
+ |);
99
103
"# ] ] ,
100
104
) ;
101
105
}
Original file line number Diff line number Diff line change @@ -98,11 +98,6 @@ pub(crate) mod entry {
98
98
let m = p. start ( ) ;
99
99
100
100
while !p. at ( EOF ) {
101
- if p. at ( T ! [ ; ] ) {
102
- p. bump ( T ! [ ; ] ) ;
103
- continue ;
104
- }
105
-
106
101
expressions:: stmt ( p, expressions:: Semicolon :: Optional ) ;
107
102
}
108
103
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ fn expr_no_struct(p: &mut Parser) {
30
30
}
31
31
32
32
pub ( super ) fn stmt ( p : & mut Parser , semicolon : Semicolon ) {
33
+ if p. eat ( T ! [ ; ] ) {
34
+ return ;
35
+ }
36
+
33
37
let m = p. start ( ) ;
34
38
// test attr_on_expr_stmt
35
39
// fn foo() {
@@ -143,12 +147,6 @@ pub(super) fn expr_block_contents(p: &mut Parser) {
143
147
// fn f() {};
144
148
// struct S {};
145
149
// }
146
-
147
- if p. at ( T ! [ ; ] ) {
148
- p. bump ( T ! [ ; ] ) ;
149
- continue ;
150
- }
151
-
152
150
stmt ( p, Semicolon :: Required ) ;
153
151
}
154
152
}
Original file line number Diff line number Diff line change @@ -76,8 +76,7 @@ impl<'a> LexedStr<'a> {
76
76
builder. eat_trivias ( ) ;
77
77
( builder. sink ) ( StrStep :: Exit ) ;
78
78
}
79
- State :: PendingEnter => ( ) ,
80
- State :: Normal => unreachable ! ( ) ,
79
+ State :: PendingEnter | State :: Normal => ( ) ,
81
80
}
82
81
83
82
let is_eof = builder. pos == builder. lexed . len ( ) ;
@@ -101,9 +100,8 @@ enum State {
101
100
impl Builder < ' _ , ' _ > {
102
101
fn token ( & mut self , kind : SyntaxKind , n_tokens : u8 ) {
103
102
match mem:: replace ( & mut self . state , State :: Normal ) {
104
- State :: PendingEnter => unreachable ! ( ) ,
105
103
State :: PendingExit => ( self . sink ) ( StrStep :: Exit ) ,
106
- State :: Normal => ( ) ,
104
+ State :: PendingEnter | State :: Normal => ( ) ,
107
105
}
108
106
self . eat_trivias ( ) ;
109
107
self . do_token ( kind, n_tokens as usize ) ;
You can’t perform that action at this time.
0 commit comments