11use super :: pat:: Expected ;
2- use super :: ty:: { AllowPlus , RecoverQuestionMark } ;
32use 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 ,
65} ;
76
87use crate :: lexer:: UnmatchedBrace ;
@@ -1233,26 +1232,14 @@ impl<'a> Parser<'a> {
12331232 }
12341233 }
12351234
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 {
12431237 self . sess . emit_err ( AmbiguousPlus { sum_ty : pprust:: ty_to_string ( & ty) , span : ty. span } ) ;
12441238 }
12451239 }
12461240
12471241 /// 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 > {
12561243 if self . token == token:: Question {
12571244 self . bump ( ) ;
12581245 self . struct_span_err ( self . prev_token . span , "invalid `?` in type" )
@@ -1272,13 +1259,9 @@ impl<'a> Parser<'a> {
12721259 }
12731260 }
12741261
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 , ( ) > {
12801263 // 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 ( ) {
12821265 return Ok ( ( ) ) ;
12831266 }
12841267
@@ -1444,10 +1427,9 @@ impl<'a> Parser<'a> {
14441427 pub ( super ) fn maybe_recover_from_bad_qpath < T : RecoverQPath > (
14451428 & mut self ,
14461429 base : P < T > ,
1447- allow_recovery : bool ,
14481430 ) -> PResult < ' a , P < T > > {
14491431 // Do not add `::` to expected tokens.
1450- if allow_recovery && self . token == token:: ModSep {
1432+ if self . token == token:: ModSep {
14511433 if let Some ( ty) = base. to_ty ( ) {
14521434 return self . maybe_recover_from_bad_qpath_stage_2 ( ty. span , ty) ;
14531435 }
@@ -1593,7 +1575,7 @@ impl<'a> Parser<'a> {
15931575 _ => ExprKind :: Await ( expr) ,
15941576 } ;
15951577 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)
15971579 }
15981580
15991581 fn recover_await_macro ( & mut self ) -> PResult < ' a , ( Span , P < Expr > , bool ) > {
@@ -2457,10 +2439,9 @@ impl<'a> Parser<'a> {
24572439 pub ( crate ) fn maybe_recover_colon_colon_in_pat_typo (
24582440 & mut self ,
24592441 mut first_pat : P < Pat > ,
2460- ra : RecoverColon ,
24612442 expected : Expected ,
24622443 ) -> P < Pat > {
2463- if RecoverColon :: Yes != ra || token:: Colon != self . token . kind {
2444+ if token:: Colon != self . token . kind {
24642445 return first_pat;
24652446 }
24662447 if !matches ! ( first_pat. kind, PatKind :: Ident ( _, _, None ) | PatKind :: Path ( ..) )
@@ -2594,10 +2575,9 @@ impl<'a> Parser<'a> {
25942575 pub ( crate ) fn maybe_recover_unexpected_comma (
25952576 & mut self ,
25962577 lo : Span ,
2597- rc : RecoverComma ,
25982578 rt : CommaRecoveryMode ,
25992579 ) -> PResult < ' a , ( ) > {
2600- if rc == RecoverComma :: No || self . token != token:: Comma {
2580+ if self . token != token:: Comma {
26012581 return Ok ( ( ) ) ;
26022582 }
26032583
0 commit comments