@@ -11,12 +11,12 @@ use crate::errors::{
1111 DoubleColonInBound , ExpectedIdentifier , ExpectedSemi , ExpectedSemiSugg ,
1212 GenericParamsWithoutAngleBrackets , GenericParamsWithoutAngleBracketsSugg ,
1313 HelpIdentifierStartsWithNumber , InInTypo , IncorrectAwait , IncorrectSemicolon ,
14- IncorrectUseOfAwait , ParenthesesInForHead , ParenthesesInForHeadSugg ,
15- PatternMethodParamWithoutBody , QuestionMarkInType , QuestionMarkInTypeSugg , SelfParamNotFirst ,
16- StructLiteralBodyWithoutPath , StructLiteralBodyWithoutPathSugg , StructLiteralNeedingParens ,
17- StructLiteralNeedingParensSugg , SuggAddMissingLetStmt , SuggEscapeIdentifier , SuggRemoveComma ,
18- TernaryOperator , UnexpectedConstInGenericParam , UnexpectedConstParamDeclaration ,
19- UnexpectedConstParamDeclarationSugg , UnmatchedAngleBrackets , UseEqInstead , WrapType ,
14+ IncorrectUseOfAwait , PatternMethodParamWithoutBody , QuestionMarkInType , QuestionMarkInTypeSugg ,
15+ SelfParamNotFirst , StructLiteralBodyWithoutPath , StructLiteralBodyWithoutPathSugg ,
16+ StructLiteralNeedingParens , StructLiteralNeedingParensSugg , SuggAddMissingLetStmt ,
17+ SuggEscapeIdentifier , SuggRemoveComma , TernaryOperator , UnexpectedConstInGenericParam ,
18+ UnexpectedConstParamDeclaration , UnexpectedConstParamDeclarationSugg , UnmatchedAngleBrackets ,
19+ UseEqInstead , WrapType ,
2020} ;
2121
2222use crate :: fluent_generated as fluent;
@@ -1994,37 +1994,6 @@ impl<'a> Parser<'a> {
19941994 }
19951995 }
19961996
1997- /// Recovers a situation like `for ( $pat in $expr )`
1998- /// and suggest writing `for $pat in $expr` instead.
1999- ///
2000- /// This should be called before parsing the `$block`.
2001- pub ( super ) fn recover_parens_around_for_head (
2002- & mut self ,
2003- pat : P < Pat > ,
2004- begin_paren : Option < ( Span , Span ) > ,
2005- ) -> P < Pat > {
2006- match ( & self . token . kind , begin_paren) {
2007- ( token:: CloseDelim ( Delimiter :: Parenthesis ) , Some ( ( begin_par_sp, left) ) ) => {
2008- let right = self . prev_token . span . between ( self . look_ahead ( 1 , |t| t. span ) ) ;
2009- self . bump ( ) ;
2010- self . sess . emit_err ( ParenthesesInForHead {
2011- span : vec ! [ begin_par_sp, self . prev_token. span] ,
2012- // With e.g. `for (x) in y)` this would replace `(x) in y)`
2013- // with `x) in y)` which is syntactically invalid.
2014- // However, this is prevented before we get here.
2015- sugg : ParenthesesInForHeadSugg { left, right } ,
2016- } ) ;
2017-
2018- // Unwrap `(pat)` into `pat` to avoid the `unused_parens` lint.
2019- pat. and_then ( |pat| match pat. kind {
2020- PatKind :: Paren ( pat) => pat,
2021- _ => P ( pat) ,
2022- } )
2023- }
2024- _ => pat,
2025- }
2026- }
2027-
20281997 pub ( super ) fn recover_seq_parse_error (
20291998 & mut self ,
20301999 delim : Delimiter ,
0 commit comments