@@ -31,16 +31,15 @@ use crate::errors::{
3131 AddParen , AmbiguousPlus , AsyncMoveBlockIn2015 , AsyncUseBlockIn2015 , AttributeOnParamType ,
3232 AwaitSuggestion , BadQPathStage2 , BadTypePlus , BadTypePlusSub , ColonAsSemi ,
3333 ComparisonOperatorsCannotBeChained , ComparisonOperatorsCannotBeChainedSugg ,
34- ConstGenericWithoutBraces , ConstGenericWithoutBracesSugg , DocCommentDoesNotDocumentAnything ,
35- DocCommentOnParamType , DoubleColonInBound , ExpectedIdentifier , ExpectedSemi , ExpectedSemiSugg ,
36- GenericParamsWithoutAngleBrackets , GenericParamsWithoutAngleBracketsSugg ,
37- HelpIdentifierStartsWithNumber , HelpUseLatestEdition , InInTypo , IncorrectAwait ,
38- IncorrectSemicolon , IncorrectUseOfAwait , IncorrectUseOfUse , PatternMethodParamWithoutBody ,
39- QuestionMarkInType , QuestionMarkInTypeSugg , SelfParamNotFirst , StructLiteralBodyWithoutPath ,
40- StructLiteralBodyWithoutPathSugg , SuggAddMissingLetStmt , SuggEscapeIdentifier , SuggRemoveComma ,
41- TernaryOperator , TernaryOperatorSuggestion , UnexpectedConstInGenericParam ,
42- UnexpectedConstParamDeclaration , UnexpectedConstParamDeclarationSugg , UnmatchedAngleBrackets ,
43- UseEqInstead , WrapType ,
34+ DocCommentDoesNotDocumentAnything , DocCommentOnParamType , DoubleColonInBound ,
35+ ExpectedIdentifier , ExpectedSemi , ExpectedSemiSugg , GenericParamsWithoutAngleBrackets ,
36+ GenericParamsWithoutAngleBracketsSugg , HelpIdentifierStartsWithNumber , HelpUseLatestEdition ,
37+ InInTypo , IncorrectAwait , IncorrectSemicolon , IncorrectUseOfAwait , IncorrectUseOfUse ,
38+ PatternMethodParamWithoutBody , QuestionMarkInType , QuestionMarkInTypeSugg , SelfParamNotFirst ,
39+ StructLiteralBodyWithoutPath , StructLiteralBodyWithoutPathSugg , SuggAddMissingLetStmt ,
40+ SuggEscapeIdentifier , SuggRemoveComma , TernaryOperator , TernaryOperatorSuggestion ,
41+ UnexpectedConstInGenericParam , UnexpectedConstParamDeclaration ,
42+ UnexpectedConstParamDeclarationSugg , UnmatchedAngleBrackets , UseEqInstead , WrapType ,
4443} ;
4544use crate :: parser:: FnContext ;
4645use crate :: parser:: attr:: InnerAttrPolicy ;
@@ -2558,36 +2557,6 @@ impl<'a> Parser<'a> {
25582557 Ok ( false ) // Don't continue.
25592558 }
25602559
2561- /// Attempt to parse a generic const argument that has not been enclosed in braces.
2562- /// There are a limited number of expressions that are permitted without being encoded
2563- /// in braces:
2564- /// - Literals.
2565- /// - Single-segment paths (i.e. standalone generic const parameters).
2566- /// All other expressions that can be parsed will emit an error suggesting the expression be
2567- /// wrapped in braces.
2568- pub ( super ) fn handle_unambiguous_unbraced_const_arg ( & mut self ) -> PResult < ' a , Box < Expr > > {
2569- let start = self . token . span ;
2570- let attrs = self . parse_outer_attributes ( ) ?;
2571- let ( expr, _) =
2572- self . parse_expr_res ( Restrictions :: CONST_EXPR , attrs) . map_err ( |mut err| {
2573- err. span_label (
2574- start. shrink_to_lo ( ) ,
2575- "while parsing a const generic argument starting here" ,
2576- ) ;
2577- err
2578- } ) ?;
2579- if !self . expr_is_valid_const_arg ( & expr) {
2580- self . dcx ( ) . emit_err ( ConstGenericWithoutBraces {
2581- span : expr. span ,
2582- sugg : ConstGenericWithoutBracesSugg {
2583- left : expr. span . shrink_to_lo ( ) ,
2584- right : expr. span . shrink_to_hi ( ) ,
2585- } ,
2586- } ) ;
2587- }
2588- Ok ( expr)
2589- }
2590-
25912560 fn recover_const_param_decl ( & mut self , ty_generics : Option < & Generics > ) -> Option < GenericArg > {
25922561 let snapshot = self . create_snapshot_for_diagnostic ( ) ;
25932562 let param = match self . parse_const_param ( AttrVec :: new ( ) ) {
0 commit comments