@@ -161,15 +161,24 @@ impl AttemptLocalParseRecovery {
161161#[ derive( Debug , Copy , Clone ) ]
162162struct IncDecRecovery {
163163 /// Is this increment/decrement its own statement?
164- ///
165- /// This is `None` when we are unsure.
166- standalone : Option < bool > ,
164+ standalone : IsStandalone ,
167165 /// Is this an increment or decrement?
168166 op : IncOrDec ,
169167 /// Is this pre- or postfix?
170168 fixity : UnaryFixity ,
171169}
172170
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+
173182#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
174183enum IncOrDec {
175184 Inc ,
@@ -1226,11 +1235,9 @@ impl<'a> Parser<'a> {
12261235 op_span : Span ,
12271236 prev_is_semi : bool ,
12281237 ) -> 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 } ;
12341241
12351242 self . recover_from_inc_dec ( operand_expr, kind, op_span)
12361243 }
@@ -1240,8 +1247,11 @@ impl<'a> Parser<'a> {
12401247 operand_expr : P < Expr > ,
12411248 op_span : Span ,
12421249 ) -> 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+ } ;
12451255
12461256 self . recover_from_inc_dec ( operand_expr, kind, op_span)
12471257 }
@@ -1271,8 +1281,10 @@ impl<'a> Parser<'a> {
12711281 } ;
12721282
12731283 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 => {
12761288 let Ok ( base_src) = self . span_to_snippet ( base. span )
12771289 else { return help_base_case ( err, base) } ;
12781290 match kind. fixity {
@@ -1284,7 +1296,7 @@ impl<'a> Parser<'a> {
12841296 }
12851297 }
12861298 }
1287- None => {
1299+ IsStandalone :: Maybe => {
12881300 let Ok ( base_src) = self . span_to_snippet ( base. span )
12891301 else { return help_base_case ( err, base) } ;
12901302 match kind. fixity {
0 commit comments