@@ -159,8 +159,6 @@ enum IsStandalone {
159
159
Standalone ,
160
160
/// It's a subexpression, i.e., *not* standalone.
161
161
Subexpr ,
162
- /// It's maybe standalone; we're not sure.
163
- Maybe ,
164
162
}
165
163
166
164
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
@@ -213,14 +211,8 @@ impl MultiSugg {
213
211
err. multipart_suggestion ( & self . msg , self . patches , self . applicability ) ;
214
212
}
215
213
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 ) ;
224
216
}
225
217
}
226
218
@@ -1272,21 +1264,20 @@ impl<'a> Parser<'a> {
1272
1264
let standalone =
1273
1265
if prev_is_semi { IsStandalone :: Standalone } else { IsStandalone :: Subexpr } ;
1274
1266
let kind = IncDecRecovery { standalone, op : IncOrDec :: Inc , fixity : UnaryFixity :: Pre } ;
1275
-
1276
1267
self . recover_from_inc_dec ( operand_expr, kind, op_span)
1277
1268
}
1278
1269
1279
1270
pub ( super ) fn recover_from_postfix_increment (
1280
1271
& mut self ,
1281
1272
operand_expr : P < Expr > ,
1282
1273
op_span : Span ,
1274
+ prev_is_semi : bool ,
1283
1275
) -> PResult < ' a , P < Expr > > {
1284
1276
let kind = IncDecRecovery {
1285
- standalone : IsStandalone :: Maybe ,
1277
+ standalone : if prev_is_semi { IsStandalone :: Standalone } else { IsStandalone :: Subexpr } ,
1286
1278
op : IncOrDec :: Inc ,
1287
1279
fixity : UnaryFixity :: Post ,
1288
1280
} ;
1289
-
1290
1281
self . recover_from_inc_dec ( operand_expr, kind, op_span)
1291
1282
}
1292
1283
@@ -1314,35 +1305,20 @@ impl<'a> Parser<'a> {
1314
1305
UnaryFixity :: Post => ( base. span . shrink_to_lo ( ) , op_span) ,
1315
1306
} ;
1316
1307
1308
+ let Ok ( base_src) = self . span_to_snippet ( base. span )
1309
+ else { return help_base_case ( err, base) } ;
1317
1310
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)
1345
1313
}
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
+ } ,
1346
1322
}
1347
1323
Err ( err)
1348
1324
}
@@ -1392,7 +1368,6 @@ impl<'a> Parser<'a> {
1392
1368
}
1393
1369
1394
1370
patches. push ( ( post_span, format ! ( " {}= 1" , kind. op. chr( ) ) ) ) ;
1395
-
1396
1371
MultiSugg {
1397
1372
msg : format ! ( "use `{}= 1` instead" , kind. op. chr( ) ) ,
1398
1373
patches,
0 commit comments