@@ -20,6 +20,7 @@ enum AttrError {
2020 MultipleItem ( String ) ,
2121 UnknownMetaItem ( String , & ' static [ & ' static str ] ) ,
2222 MissingSince ,
23+ NonIdentFeature ,
2324 MissingFeature ,
2425 MultipleStabilityLevels ,
2526 UnsupportedLiteral ( & ' static str , /* is_bytestr */ bool ) ,
@@ -40,6 +41,9 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
4041 AttrError :: MissingSince => {
4142 struct_span_err ! ( diag, span, E0542 , "missing 'since'" ) . emit ( ) ;
4243 }
44+ AttrError :: NonIdentFeature => {
45+ struct_span_err ! ( diag, span, E0546 , "'feature' is not an identifier" ) . emit ( ) ;
46+ }
4347 AttrError :: MissingFeature => {
4448 struct_span_err ! ( diag, span, E0546 , "missing 'feature'" ) . emit ( ) ;
4549 }
@@ -344,6 +348,14 @@ where
344348
345349 match ( feature, reason, issue) {
346350 ( Some ( feature) , reason, Some ( _) ) => {
351+ if !rustc_lexer:: is_ident ( & feature. as_str ( ) ) {
352+ handle_errors (
353+ & sess. parse_sess ,
354+ attr. span ,
355+ AttrError :: NonIdentFeature ,
356+ ) ;
357+ continue ;
358+ }
347359 let level = Unstable { reason, issue : issue_num, is_soft } ;
348360 if sym:: unstable == meta_name {
349361 stab = Some ( Stability { level, feature } ) ;
0 commit comments