@@ -6,14 +6,14 @@ use super::{
6
6
use crate :: errors:: {
7
7
AmbiguousPlus , AttributeOnParamType , BadQPathStage2 , BadTypePlus , BadTypePlusSub ,
8
8
ComparisonOperatorsCannotBeChained , ComparisonOperatorsCannotBeChainedSugg ,
9
- ConstGenericWithoutBraces , ConstGenericWithoutBracesSugg , DocCommentOnParamType ,
10
- DoubleColonInBound , ExpectedIdentifier , ExpectedSemi , ExpectedSemiSugg ,
9
+ ConstGenericWithoutBraces , ConstGenericWithoutBracesSugg , DocCommentDoesNotDocumentAnything ,
10
+ DocCommentOnParamType , DoubleColonInBound , ExpectedIdentifier , ExpectedSemi , ExpectedSemiSugg ,
11
11
GenericParamsWithoutAngleBrackets , GenericParamsWithoutAngleBracketsSugg ,
12
12
HelpIdentifierStartsWithNumber , InInTypo , IncorrectAwait , IncorrectSemicolon ,
13
13
IncorrectUseOfAwait , ParenthesesInForHead , ParenthesesInForHeadSugg ,
14
14
PatternMethodParamWithoutBody , QuestionMarkInType , QuestionMarkInTypeSugg , SelfParamNotFirst ,
15
15
StructLiteralBodyWithoutPath , StructLiteralBodyWithoutPathSugg , StructLiteralNeedingParens ,
16
- StructLiteralNeedingParensSugg , SuggEscapeToUseAsIdentifier , SuggRemoveComma ,
16
+ StructLiteralNeedingParensSugg , SuggEscapeIdentifier , SuggRemoveComma ,
17
17
UnexpectedConstInGenericParam , UnexpectedConstParamDeclaration ,
18
18
UnexpectedConstParamDeclarationSugg , UnmatchedAngleBrackets , UseEqInstead ,
19
19
} ;
@@ -268,7 +268,16 @@ impl<'a> Parser<'a> {
268
268
self . sess . source_map ( ) . span_to_snippet ( span)
269
269
}
270
270
271
+ /// Emits an error with suggestions if an identifier was expected but not found.
271
272
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
+
272
281
let valid_follow = & [
273
282
TokenKind :: Eq ,
274
283
TokenKind :: Colon ,
@@ -286,7 +295,7 @@ impl<'a> Parser<'a> {
286
295
if ident. is_raw_guess ( )
287
296
&& self . look_ahead ( 1 , |t| valid_follow. contains ( & t. kind ) ) =>
288
297
{
289
- Some ( SuggEscapeToUseAsIdentifier {
298
+ Some ( SuggEscapeIdentifier {
290
299
span : ident. span . shrink_to_lo ( ) ,
291
300
// `Symbol::to_string()` is different from `Symbol::into_diagnostic_arg()`,
292
301
// which uses `Symbol::to_ident_string()` and "helpfully" adds an implicit `r#`
0 commit comments