@@ -159,8 +159,6 @@ enum IsStandalone {
159159 Standalone ,
160160 /// It's a subexpression, i.e., *not* standalone.
161161 Subexpr ,
162- /// It's maybe standalone; we're not sure.
163- Maybe ,
164162}
165163
166164#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
@@ -213,14 +211,8 @@ impl MultiSugg {
213211 err. multipart_suggestion ( & self . msg , self . patches , self . applicability ) ;
214212 }
215213
216- /// Overrides individual messages and applicabilities.
217- fn emit_many (
218- err : & mut Diagnostic ,
219- msg : & str ,
220- applicability : Applicability ,
221- suggestions : impl Iterator < Item = Self > ,
222- ) {
223- err. multipart_suggestions ( msg, suggestions. map ( |s| s. patches ) , applicability) ;
214+ fn emit_verbose ( self , err : & mut Diagnostic ) {
215+ err. multipart_suggestion_verbose ( & self . msg , self . patches , self . applicability ) ;
224216 }
225217}
226218
@@ -1272,21 +1264,20 @@ impl<'a> Parser<'a> {
12721264 let standalone =
12731265 if prev_is_semi { IsStandalone :: Standalone } else { IsStandalone :: Subexpr } ;
12741266 let kind = IncDecRecovery { standalone, op : IncOrDec :: Inc , fixity : UnaryFixity :: Pre } ;
1275-
12761267 self . recover_from_inc_dec ( operand_expr, kind, op_span)
12771268 }
12781269
12791270 pub ( super ) fn recover_from_postfix_increment (
12801271 & mut self ,
12811272 operand_expr : P < Expr > ,
12821273 op_span : Span ,
1274+ prev_is_semi : bool ,
12831275 ) -> PResult < ' a , P < Expr > > {
12841276 let kind = IncDecRecovery {
1285- standalone : IsStandalone :: Maybe ,
1277+ standalone : if prev_is_semi { IsStandalone :: Standalone } else { IsStandalone :: Subexpr } ,
12861278 op : IncOrDec :: Inc ,
12871279 fixity : UnaryFixity :: Post ,
12881280 } ;
1289-
12901281 self . recover_from_inc_dec ( operand_expr, kind, op_span)
12911282 }
12921283
@@ -1314,35 +1305,20 @@ impl<'a> Parser<'a> {
13141305 UnaryFixity :: Post => ( base. span . shrink_to_lo ( ) , op_span) ,
13151306 } ;
13161307
1308+ let Ok ( base_src) = self . span_to_snippet ( base. span )
1309+ else { return help_base_case ( err, base) } ;
13171310 match kind. standalone {
1318- IsStandalone :: Standalone => self . inc_dec_standalone_suggest ( kind, spans) . emit ( & mut err) ,
1319- IsStandalone :: Subexpr => {
1320- let Ok ( base_src) = self . span_to_snippet ( base. span )
1321- else { return help_base_case ( err, base) } ;
1322- match kind. fixity {
1323- UnaryFixity :: Pre => {
1324- self . prefix_inc_dec_suggest ( base_src, kind, spans) . emit ( & mut err)
1325- }
1326- UnaryFixity :: Post => {
1327- self . postfix_inc_dec_suggest ( base_src, kind, spans) . emit ( & mut err)
1328- }
1329- }
1330- }
1331- IsStandalone :: Maybe => {
1332- let Ok ( base_src) = self . span_to_snippet ( base. span )
1333- else { return help_base_case ( err, base) } ;
1334- let sugg1 = match kind. fixity {
1335- UnaryFixity :: Pre => self . prefix_inc_dec_suggest ( base_src, kind, spans) ,
1336- UnaryFixity :: Post => self . postfix_inc_dec_suggest ( base_src, kind, spans) ,
1337- } ;
1338- let sugg2 = self . inc_dec_standalone_suggest ( kind, spans) ;
1339- MultiSugg :: emit_many (
1340- & mut err,
1341- "use `+= 1` instead" ,
1342- Applicability :: Unspecified ,
1343- [ sugg1, sugg2] . into_iter ( ) ,
1344- )
1311+ IsStandalone :: Standalone => {
1312+ self . inc_dec_standalone_suggest ( kind, spans) . emit_verbose ( & mut err)
13451313 }
1314+ IsStandalone :: Subexpr => match kind. fixity {
1315+ UnaryFixity :: Pre => {
1316+ self . prefix_inc_dec_suggest ( base_src, kind, spans) . emit ( & mut err)
1317+ }
1318+ UnaryFixity :: Post => {
1319+ self . postfix_inc_dec_suggest ( base_src, kind, spans) . emit ( & mut err)
1320+ }
1321+ } ,
13461322 }
13471323 Err ( err)
13481324 }
@@ -1392,7 +1368,6 @@ impl<'a> Parser<'a> {
13921368 }
13931369
13941370 patches. push ( ( post_span, format ! ( " {}= 1" , kind. op. chr( ) ) ) ) ;
1395-
13961371 MultiSugg {
13971372 msg : format ! ( "use `{}= 1` instead" , kind. op. chr( ) ) ,
13981373 patches,
0 commit comments