@@ -10,51 +10,54 @@ pub(crate) fn requires_semi_to_be_stmt(expr: &Expr) -> bool {
10
10
}
11
11
}
12
12
13
- pub ( crate ) fn requires_comma_to_be_match_arm ( expr : & Expr ) -> bool {
14
- match expr {
15
- #![ cfg_attr( all( test, exhaustive) , deny( non_exhaustive_omitted_patterns) ) ]
16
- Expr :: If ( _)
17
- | Expr :: Match ( _)
18
- | Expr :: Block ( _) | Expr :: Unsafe ( _) // both under ExprKind::Block in rustc
19
- | Expr :: While ( _)
20
- | Expr :: Loop ( _)
21
- | Expr :: ForLoop ( _)
22
- | Expr :: TryBlock ( _)
23
- | Expr :: Const ( _) => false ,
13
+ pub ( crate ) fn requires_comma_to_be_match_arm ( mut expr : & Expr ) -> bool {
14
+ loop {
15
+ match expr {
16
+ #![ cfg_attr( all( test, exhaustive) , deny( non_exhaustive_omitted_patterns) ) ]
17
+ Expr :: If ( _)
18
+ | Expr :: Match ( _)
19
+ | Expr :: Block ( _) | Expr :: Unsafe ( _) // both under ExprKind::Block in rustc
20
+ | Expr :: While ( _)
21
+ | Expr :: Loop ( _)
22
+ | Expr :: ForLoop ( _)
23
+ | Expr :: TryBlock ( _)
24
+ | Expr :: Const ( _) => return false ,
25
+
26
+ Expr :: Array ( _)
27
+ | Expr :: Assign ( _)
28
+ | Expr :: Async ( _)
29
+ | Expr :: Await ( _)
30
+ | Expr :: Binary ( _)
31
+ | Expr :: Break ( _)
32
+ | Expr :: Call ( _)
33
+ | Expr :: Cast ( _)
34
+ | Expr :: Closure ( _)
35
+ | Expr :: Continue ( _)
36
+ | Expr :: Field ( _)
37
+ | Expr :: Index ( _)
38
+ | Expr :: Infer ( _)
39
+ | Expr :: Let ( _)
40
+ | Expr :: Lit ( _)
41
+ | Expr :: Macro ( _)
42
+ | Expr :: MethodCall ( _)
43
+ | Expr :: Paren ( _)
44
+ | Expr :: Path ( _)
45
+ | Expr :: Range ( _)
46
+ | Expr :: RawAddr ( _)
47
+ | Expr :: Reference ( _)
48
+ | Expr :: Repeat ( _)
49
+ | Expr :: Return ( _)
50
+ | Expr :: Struct ( _)
51
+ | Expr :: Try ( _)
52
+ | Expr :: Tuple ( _)
53
+ | Expr :: Unary ( _)
54
+ | Expr :: Yield ( _)
55
+ | Expr :: Verbatim ( _) => return true ,
24
56
25
- Expr :: Array ( _)
26
- | Expr :: Assign ( _)
27
- | Expr :: Async ( _)
28
- | Expr :: Await ( _)
29
- | Expr :: Binary ( _)
30
- | Expr :: Break ( _)
31
- | Expr :: Call ( _)
32
- | Expr :: Cast ( _)
33
- | Expr :: Closure ( _)
34
- | Expr :: Continue ( _)
35
- | Expr :: Field ( _)
36
- | Expr :: Group ( _)
37
- | Expr :: Index ( _)
38
- | Expr :: Infer ( _)
39
- | Expr :: Let ( _)
40
- | Expr :: Lit ( _)
41
- | Expr :: Macro ( _)
42
- | Expr :: MethodCall ( _)
43
- | Expr :: Paren ( _)
44
- | Expr :: Path ( _)
45
- | Expr :: Range ( _)
46
- | Expr :: RawAddr ( _)
47
- | Expr :: Reference ( _)
48
- | Expr :: Repeat ( _)
49
- | Expr :: Return ( _)
50
- | Expr :: Struct ( _)
51
- | Expr :: Try ( _)
52
- | Expr :: Tuple ( _)
53
- | Expr :: Unary ( _)
54
- | Expr :: Yield ( _)
55
- | Expr :: Verbatim ( _) => true ,
57
+ Expr :: Group ( group) => expr = & group. expr ,
56
58
57
- _ => true ,
59
+ _ => return true ,
60
+ }
58
61
}
59
62
}
60
63
@@ -150,7 +153,6 @@ pub(crate) fn expr_leading_label(mut expr: &Expr) -> bool {
150
153
| Expr :: Closure ( _)
151
154
| Expr :: Const ( _)
152
155
| Expr :: Continue ( _)
153
- | Expr :: Group ( _)
154
156
| Expr :: If ( _)
155
157
| Expr :: Infer ( _)
156
158
| Expr :: Let ( _)
@@ -171,6 +173,13 @@ pub(crate) fn expr_leading_label(mut expr: &Expr) -> bool {
171
173
| Expr :: Verbatim ( _)
172
174
| Expr :: Yield ( _) => return false ,
173
175
176
+ Expr :: Group ( e) => {
177
+ if !e. attrs . is_empty ( ) {
178
+ return false ;
179
+ }
180
+ expr = & e. expr ;
181
+ }
182
+
174
183
_ => return false ,
175
184
}
176
185
}
@@ -201,6 +210,7 @@ pub(crate) fn expr_trailing_brace(mut expr: &Expr) -> bool {
201
210
} ,
202
211
Expr :: Cast ( e) => return type_trailing_brace ( & e. ty ) ,
203
212
Expr :: Closure ( e) => expr = & e. body ,
213
+ Expr :: Group ( e) => expr = & e. expr ,
204
214
Expr :: Let ( e) => expr = & e. expr ,
205
215
Expr :: Macro ( e) => return matches ! ( e. mac. delimiter, MacroDelimiter :: Brace ( _) ) ,
206
216
Expr :: Range ( e) => match & e. end {
@@ -225,7 +235,6 @@ pub(crate) fn expr_trailing_brace(mut expr: &Expr) -> bool {
225
235
| Expr :: Call ( _)
226
236
| Expr :: Continue ( _)
227
237
| Expr :: Field ( _)
228
- | Expr :: Group ( _)
229
238
| Expr :: Index ( _)
230
239
| Expr :: Infer ( _)
231
240
| Expr :: Lit ( _)
0 commit comments