@@ -10,13 +10,13 @@ use crate::errors::{
10
10
ConstGenericWithoutBracesSugg , DocCommentDoesNotDocumentAnything , DocCommentOnParamType ,
11
11
DoubleColonInBound , ExpectedIdentifier , ExpectedSemi , ExpectedSemiSugg ,
12
12
GenericParamsWithoutAngleBrackets , GenericParamsWithoutAngleBracketsSugg ,
13
- HelpIdentifierStartsWithNumber , InInTypo , IncorrectAwait , IncorrectSemicolon ,
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 ,
13
+ HelpIdentifierStartsWithNumber , HelpUseLatestEdition , InInTypo , IncorrectAwait ,
14
+ IncorrectSemicolon , IncorrectUseOfAwait , PatternMethodParamWithoutBody , QuestionMarkInType ,
15
+ QuestionMarkInTypeSugg , SelfParamNotFirst , StructLiteralBodyWithoutPath ,
16
+ StructLiteralBodyWithoutPathSugg , StructLiteralNeedingParens , StructLiteralNeedingParensSugg ,
17
+ SuggAddMissingLetStmt , SuggEscapeIdentifier , SuggRemoveComma , TernaryOperator ,
18
+ UnexpectedConstInGenericParam , UnexpectedConstParamDeclaration ,
19
+ UnexpectedConstParamDeclarationSugg , UnmatchedAngleBrackets , UseEqInstead , WrapType ,
20
20
} ;
21
21
use crate :: fluent_generated as fluent;
22
22
use crate :: parser;
@@ -640,6 +640,17 @@ impl<'a> Parser<'a> {
640
640
}
641
641
}
642
642
643
+ // extra info for `c"str"` before 2021 edition or `c "str"` in all editions
644
+ if self . prev_token . is_ident_named ( Symbol :: intern ( "c" ) )
645
+ && let TokenKind :: Literal ( token:: Lit { kind : token:: Str | token:: StrRaw ( ..) , .. } ) =
646
+ & self . token . kind
647
+ {
648
+ err. note ( "you may be trying to declare a CStr literal" ) ;
649
+ err. note ( "`CStr` literals require edition 2021" ) ;
650
+ HelpUseLatestEdition :: new ( ) . add_to_diagnostic ( & mut err) ;
651
+ err. note ( "`c` modifier in CStr literal cannot be followed by whitespace" ) ;
652
+ }
653
+
643
654
// `pub` may be used for an item or `pub(crate)`
644
655
if self . prev_token . is_ident_named ( sym:: public)
645
656
&& ( self . token . can_begin_item ( )
0 commit comments