@@ -6,14 +6,14 @@ use super::{
66use crate :: errors:: {
77 AmbiguousPlus , AttributeOnParamType , BadQPathStage2 , BadTypePlus , BadTypePlusSub ,
88 ComparisonOperatorsCannotBeChained , ComparisonOperatorsCannotBeChainedSugg ,
9- ConstGenericWithoutBraces , ConstGenericWithoutBracesSugg , DocCommentOnParamType ,
10- DoubleColonInBound , ExpectedIdentifier , ExpectedSemi , ExpectedSemiSugg ,
9+ ConstGenericWithoutBraces , ConstGenericWithoutBracesSugg , DocCommentDoesNotDocumentAnything ,
10+ DocCommentOnParamType , DoubleColonInBound , ExpectedIdentifier , ExpectedSemi , ExpectedSemiSugg ,
1111 GenericParamsWithoutAngleBrackets , GenericParamsWithoutAngleBracketsSugg ,
1212 HelpIdentifierStartsWithNumber , InInTypo , IncorrectAwait , IncorrectSemicolon ,
1313 IncorrectUseOfAwait , ParenthesesInForHead , ParenthesesInForHeadSugg ,
1414 PatternMethodParamWithoutBody , QuestionMarkInType , QuestionMarkInTypeSugg , SelfParamNotFirst ,
1515 StructLiteralBodyWithoutPath , StructLiteralBodyWithoutPathSugg , StructLiteralNeedingParens ,
16- StructLiteralNeedingParensSugg , SuggEscapeToUseAsIdentifier , SuggRemoveComma ,
16+ StructLiteralNeedingParensSugg , SuggEscapeIdentifier , SuggRemoveComma ,
1717 UnexpectedConstInGenericParam , UnexpectedConstParamDeclaration ,
1818 UnexpectedConstParamDeclarationSugg , UnmatchedAngleBrackets , UseEqInstead ,
1919} ;
@@ -268,7 +268,16 @@ impl<'a> Parser<'a> {
268268 self . sess . source_map ( ) . span_to_snippet ( span)
269269 }
270270
271+ /// Emits an error with suggestions if an identifier was expected but not found.
271272 pub ( super ) fn expected_ident_found ( & mut self ) -> DiagnosticBuilder < ' a , ErrorGuaranteed > {
273+ if let TokenKind :: DocComment ( ..) = self . prev_token . kind {
274+ return DocCommentDoesNotDocumentAnything {
275+ span : self . prev_token . span ,
276+ missing_comma : None ,
277+ }
278+ . into_diagnostic ( & self . sess . span_diagnostic ) ;
279+ }
280+
272281 let valid_follow = & [
273282 TokenKind :: Eq ,
274283 TokenKind :: Colon ,
@@ -286,7 +295,7 @@ impl<'a> Parser<'a> {
286295 if ident. is_raw_guess ( )
287296 && self . look_ahead ( 1 , |t| valid_follow. contains ( & t. kind ) ) =>
288297 {
289- Some ( SuggEscapeToUseAsIdentifier {
298+ Some ( SuggEscapeIdentifier {
290299 span : ident. span . shrink_to_lo ( ) ,
291300 // `Symbol::to_string()` is different from `Symbol::into_diagnostic_arg()`,
292301 // which uses `Symbol::to_ident_string()` and "helpfully" adds an implicit `r#`
0 commit comments