@@ -161,15 +161,24 @@ impl AttemptLocalParseRecovery {
161
161
#[ derive( Debug , Copy , Clone ) ]
162
162
struct IncDecRecovery {
163
163
/// Is this increment/decrement its own statement?
164
- ///
165
- /// This is `None` when we are unsure.
166
- standalone : Option < bool > ,
164
+ standalone : IsStandalone ,
167
165
/// Is this an increment or decrement?
168
166
op : IncOrDec ,
169
167
/// Is this pre- or postfix?
170
168
fixity : UnaryFixity ,
171
169
}
172
170
171
+ /// Is an increment or decrement expression its own statement?
172
+ #[ derive( Debug , Copy , Clone ) ]
173
+ enum IsStandalone {
174
+ /// It's standalone, i.e., its own statement.
175
+ Standalone ,
176
+ /// It's a subexpression, i.e., *not* standalone.
177
+ Subexpr ,
178
+ /// It's maybe standalone; we're not sure.
179
+ Maybe ,
180
+ }
181
+
173
182
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
174
183
enum IncOrDec {
175
184
Inc ,
@@ -1226,11 +1235,9 @@ impl<'a> Parser<'a> {
1226
1235
op_span : Span ,
1227
1236
prev_is_semi : bool ,
1228
1237
) -> PResult < ' a , P < Expr > > {
1229
- let kind = IncDecRecovery {
1230
- standalone : Some ( prev_is_semi) ,
1231
- op : IncOrDec :: Inc ,
1232
- fixity : UnaryFixity :: Pre ,
1233
- } ;
1238
+ let standalone =
1239
+ if prev_is_semi { IsStandalone :: Standalone } else { IsStandalone :: Subexpr } ;
1240
+ let kind = IncDecRecovery { standalone, op : IncOrDec :: Inc , fixity : UnaryFixity :: Pre } ;
1234
1241
1235
1242
self . recover_from_inc_dec ( operand_expr, kind, op_span)
1236
1243
}
@@ -1240,8 +1247,11 @@ impl<'a> Parser<'a> {
1240
1247
operand_expr : P < Expr > ,
1241
1248
op_span : Span ,
1242
1249
) -> PResult < ' a , P < Expr > > {
1243
- let kind =
1244
- IncDecRecovery { standalone : None , op : IncOrDec :: Inc , fixity : UnaryFixity :: Post } ;
1250
+ let kind = IncDecRecovery {
1251
+ standalone : IsStandalone :: Maybe ,
1252
+ op : IncOrDec :: Inc ,
1253
+ fixity : UnaryFixity :: Post ,
1254
+ } ;
1245
1255
1246
1256
self . recover_from_inc_dec ( operand_expr, kind, op_span)
1247
1257
}
@@ -1271,8 +1281,10 @@ impl<'a> Parser<'a> {
1271
1281
} ;
1272
1282
1273
1283
match kind. standalone {
1274
- Some ( true ) => self . inc_dec_standalone_recovery ( & mut err, kind, spans, false ) ,
1275
- Some ( false ) => {
1284
+ IsStandalone :: Standalone => {
1285
+ self . inc_dec_standalone_recovery ( & mut err, kind, spans, false )
1286
+ }
1287
+ IsStandalone :: Subexpr => {
1276
1288
let Ok ( base_src) = self . span_to_snippet ( base. span )
1277
1289
else { return help_base_case ( err, base) } ;
1278
1290
match kind. fixity {
@@ -1284,7 +1296,7 @@ impl<'a> Parser<'a> {
1284
1296
}
1285
1297
}
1286
1298
}
1287
- None => {
1299
+ IsStandalone :: Maybe => {
1288
1300
let Ok ( base_src) = self . span_to_snippet ( base. span )
1289
1301
else { return help_base_case ( err, base) } ;
1290
1302
match kind. fixity {
0 commit comments