1
1
use super :: pat:: Expected ;
2
- use super :: ty:: { AllowPlus , RecoverQuestionMark } ;
3
2
use super :: {
4
- BlockMode , CommaRecoveryMode , Parser , PathStyle , RecoverColon , RecoverComma , Restrictions ,
5
- SemiColonMode , SeqSep , TokenExpectType , TokenType ,
3
+ BlockMode , CommaRecoveryMode , Parser , PathStyle , Restrictions , SemiColonMode , SeqSep ,
4
+ TokenExpectType , TokenType ,
6
5
} ;
7
6
8
7
use crate :: lexer:: UnmatchedBrace ;
@@ -1233,26 +1232,14 @@ impl<'a> Parser<'a> {
1233
1232
}
1234
1233
}
1235
1234
1236
- pub ( super ) fn maybe_report_ambiguous_plus (
1237
- & mut self ,
1238
- allow_plus : AllowPlus ,
1239
- impl_dyn_multi : bool ,
1240
- ty : & Ty ,
1241
- ) {
1242
- if matches ! ( allow_plus, AllowPlus :: No ) && impl_dyn_multi {
1235
+ pub ( super ) fn maybe_report_ambiguous_plus ( & mut self , impl_dyn_multi : bool , ty : & Ty ) {
1236
+ if impl_dyn_multi {
1243
1237
self . sess . emit_err ( AmbiguousPlus { sum_ty : pprust:: ty_to_string ( & ty) , span : ty. span } ) ;
1244
1238
}
1245
1239
}
1246
1240
1247
1241
/// Swift lets users write `Ty?` to mean `Option<Ty>`. Parse the construct and recover from it.
1248
- pub ( super ) fn maybe_recover_from_question_mark (
1249
- & mut self ,
1250
- ty : P < Ty > ,
1251
- recover_question_mark : RecoverQuestionMark ,
1252
- ) -> P < Ty > {
1253
- if let RecoverQuestionMark :: No = recover_question_mark {
1254
- return ty;
1255
- }
1242
+ pub ( super ) fn maybe_recover_from_question_mark ( & mut self , ty : P < Ty > ) -> P < Ty > {
1256
1243
if self . token == token:: Question {
1257
1244
self . bump ( ) ;
1258
1245
self . struct_span_err ( self . prev_token . span , "invalid `?` in type" )
@@ -1272,13 +1259,9 @@ impl<'a> Parser<'a> {
1272
1259
}
1273
1260
}
1274
1261
1275
- pub ( super ) fn maybe_recover_from_bad_type_plus (
1276
- & mut self ,
1277
- allow_plus : AllowPlus ,
1278
- ty : & Ty ,
1279
- ) -> PResult < ' a , ( ) > {
1262
+ pub ( super ) fn maybe_recover_from_bad_type_plus ( & mut self , ty : & Ty ) -> PResult < ' a , ( ) > {
1280
1263
// Do not add `+` to expected tokens.
1281
- if matches ! ( allow_plus , AllowPlus :: No ) || !self . token . is_like_plus ( ) {
1264
+ if !self . token . is_like_plus ( ) {
1282
1265
return Ok ( ( ) ) ;
1283
1266
}
1284
1267
@@ -1444,10 +1427,9 @@ impl<'a> Parser<'a> {
1444
1427
pub ( super ) fn maybe_recover_from_bad_qpath < T : RecoverQPath > (
1445
1428
& mut self ,
1446
1429
base : P < T > ,
1447
- allow_recovery : bool ,
1448
1430
) -> PResult < ' a , P < T > > {
1449
1431
// Do not add `::` to expected tokens.
1450
- if allow_recovery && self . token == token:: ModSep {
1432
+ if self . token == token:: ModSep {
1451
1433
if let Some ( ty) = base. to_ty ( ) {
1452
1434
return self . maybe_recover_from_bad_qpath_stage_2 ( ty. span , ty) ;
1453
1435
}
@@ -1593,7 +1575,7 @@ impl<'a> Parser<'a> {
1593
1575
_ => ExprKind :: Await ( expr) ,
1594
1576
} ;
1595
1577
let expr = self . mk_expr ( lo. to ( sp) , kind, attrs) ;
1596
- self . maybe_recover_from_bad_qpath ( expr, true )
1578
+ self . maybe_recover_from_bad_qpath ( expr)
1597
1579
}
1598
1580
1599
1581
fn recover_await_macro ( & mut self ) -> PResult < ' a , ( Span , P < Expr > , bool ) > {
@@ -2457,10 +2439,9 @@ impl<'a> Parser<'a> {
2457
2439
pub ( crate ) fn maybe_recover_colon_colon_in_pat_typo (
2458
2440
& mut self ,
2459
2441
mut first_pat : P < Pat > ,
2460
- ra : RecoverColon ,
2461
2442
expected : Expected ,
2462
2443
) -> P < Pat > {
2463
- if RecoverColon :: Yes != ra || token:: Colon != self . token . kind {
2444
+ if token:: Colon != self . token . kind {
2464
2445
return first_pat;
2465
2446
}
2466
2447
if !matches ! ( first_pat. kind, PatKind :: Ident ( _, _, None ) | PatKind :: Path ( ..) )
@@ -2594,10 +2575,9 @@ impl<'a> Parser<'a> {
2594
2575
pub ( crate ) fn maybe_recover_unexpected_comma (
2595
2576
& mut self ,
2596
2577
lo : Span ,
2597
- rc : RecoverComma ,
2598
2578
rt : CommaRecoveryMode ,
2599
2579
) -> PResult < ' a , ( ) > {
2600
- if rc == RecoverComma :: No || self . token != token:: Comma {
2580
+ if self . token != token:: Comma {
2601
2581
return Ok ( ( ) ) ;
2602
2582
}
2603
2583
0 commit comments