@@ -20,6 +20,7 @@ enum AttrError {
20
20
MultipleItem ( String ) ,
21
21
UnknownMetaItem ( String , & ' static [ & ' static str ] ) ,
22
22
MissingSince ,
23
+ NonIdentFeature ,
23
24
MissingFeature ,
24
25
MultipleStabilityLevels ,
25
26
UnsupportedLiteral ( & ' static str , /* is_bytestr */ bool ) ,
@@ -40,6 +41,9 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
40
41
AttrError :: MissingSince => {
41
42
struct_span_err ! ( diag, span, E0542 , "missing 'since'" ) . emit ( ) ;
42
43
}
44
+ AttrError :: NonIdentFeature => {
45
+ struct_span_err ! ( diag, span, E0546 , "'feature' is not an identifier" ) . emit ( ) ;
46
+ }
43
47
AttrError :: MissingFeature => {
44
48
struct_span_err ! ( diag, span, E0546 , "missing 'feature'" ) . emit ( ) ;
45
49
}
@@ -344,6 +348,14 @@ where
344
348
345
349
match ( feature, reason, issue) {
346
350
( 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
+ }
347
359
let level = Unstable { reason, issue : issue_num, is_soft } ;
348
360
if sym:: unstable == meta_name {
349
361
stab = Some ( Stability { level, feature } ) ;
0 commit comments