@@ -28,7 +28,7 @@ use crate::tokenstream::TokenTree;
28
28
use errors:: { DiagnosticBuilder , Handler } ;
29
29
use rustc_data_structures:: fx:: FxHashMap ;
30
30
use rustc_target:: spec:: abi:: Abi ;
31
- use syntax_pos:: { Span , DUMMY_SP } ;
31
+ use syntax_pos:: { Span , DUMMY_SP , symbols } ;
32
32
use log:: debug;
33
33
34
34
use std:: env;
@@ -1366,7 +1366,7 @@ impl<'a> Context<'a> {
1366
1366
}
1367
1367
} else if n == "doc" {
1368
1368
if let Some ( content) = attr. meta_item_list ( ) {
1369
- if content. iter ( ) . any ( |c| c. check_name ( " include" ) ) {
1369
+ if content. iter ( ) . any ( |c| c. check_name_symbol ( symbols :: include) ) {
1370
1370
gate_feature ! ( self , external_doc, attr. span,
1371
1371
"#[doc(include = \" ...\" )] is experimental"
1372
1372
) ;
@@ -1648,33 +1648,33 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
1648
1648
// check for gated attributes
1649
1649
self . context . check_attribute ( attr, false ) ;
1650
1650
1651
- if attr. check_name ( " doc" ) {
1651
+ if attr. check_name_symbol ( symbols :: doc) {
1652
1652
if let Some ( content) = attr. meta_item_list ( ) {
1653
- if content. len ( ) == 1 && content[ 0 ] . check_name ( " cfg" ) {
1653
+ if content. len ( ) == 1 && content[ 0 ] . check_name_symbol ( symbols :: cfg) {
1654
1654
gate_feature_post ! ( & self , doc_cfg, attr. span,
1655
1655
"#[doc(cfg(...))] is experimental"
1656
1656
) ;
1657
- } else if content. iter ( ) . any ( |c| c. check_name ( " masked" ) ) {
1657
+ } else if content. iter ( ) . any ( |c| c. check_name_symbol ( symbols :: masked) ) {
1658
1658
gate_feature_post ! ( & self , doc_masked, attr. span,
1659
1659
"#[doc(masked)] is experimental"
1660
1660
) ;
1661
- } else if content. iter ( ) . any ( |c| c. check_name ( " spotlight" ) ) {
1661
+ } else if content. iter ( ) . any ( |c| c. check_name_symbol ( symbols :: spotlight) ) {
1662
1662
gate_feature_post ! ( & self , doc_spotlight, attr. span,
1663
1663
"#[doc(spotlight)] is experimental"
1664
1664
) ;
1665
- } else if content. iter ( ) . any ( |c| c. check_name ( " alias" ) ) {
1665
+ } else if content. iter ( ) . any ( |c| c. check_name_symbol ( symbols :: alias) ) {
1666
1666
gate_feature_post ! ( & self , doc_alias, attr. span,
1667
1667
"#[doc(alias = \" ...\" )] is experimental"
1668
1668
) ;
1669
- } else if content. iter ( ) . any ( |c| c. check_name ( " keyword" ) ) {
1669
+ } else if content. iter ( ) . any ( |c| c. check_name_symbol ( symbols :: keyword) ) {
1670
1670
gate_feature_post ! ( & self , doc_keyword, attr. span,
1671
1671
"#[doc(keyword = \" ...\" )] is experimental"
1672
1672
) ;
1673
1673
}
1674
1674
}
1675
1675
}
1676
1676
1677
- match BUILTIN_ATTRIBUTES . iter ( ) . find ( |( name, ..) | attr. path == name) {
1677
+ match BUILTIN_ATTRIBUTES . iter ( ) . find ( |( name, ..) | attr. path == * name) {
1678
1678
Some ( & ( name, _, template, _) ) => self . check_builtin_attribute ( attr, name, template) ,
1679
1679
None => if let Some ( TokenTree :: Token ( _, token:: Eq ) ) = attr. tokens . trees ( ) . next ( ) {
1680
1680
// All key-value attributes are restricted to meta-item syntax.
@@ -1727,7 +1727,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
1727
1727
ast:: ItemKind :: Struct ( ..) => {
1728
1728
for attr in attr:: filter_by_name ( & i. attrs [ ..] , "repr" ) {
1729
1729
for item in attr. meta_item_list ( ) . unwrap_or_else ( Vec :: new) {
1730
- if item. check_name ( " simd" ) {
1730
+ if item. check_name_symbol ( symbols :: simd) {
1731
1731
gate_feature_post ! ( & self , repr_simd, attr. span,
1732
1732
"SIMD types are experimental and possibly buggy" ) ;
1733
1733
}
@@ -1738,7 +1738,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
1738
1738
ast:: ItemKind :: Enum ( ..) => {
1739
1739
for attr in attr:: filter_by_name ( & i. attrs [ ..] , "repr" ) {
1740
1740
for item in attr. meta_item_list ( ) . unwrap_or_else ( Vec :: new) {
1741
- if item. check_name ( " align" ) {
1741
+ if item. check_name_symbol ( symbols :: align) {
1742
1742
gate_feature_post ! ( & self , repr_align_enum, attr. span,
1743
1743
"`#[repr(align(x))]` on enums is experimental" ) ;
1744
1744
}
@@ -2062,7 +2062,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
2062
2062
// Process the edition umbrella feature-gates first, to ensure
2063
2063
// `edition_enabled_features` is completed before it's queried.
2064
2064
for attr in krate_attrs {
2065
- if !attr. check_name ( " feature" ) {
2065
+ if !attr. check_name_symbol ( symbols :: feature) {
2066
2066
continue
2067
2067
}
2068
2068
@@ -2107,7 +2107,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
2107
2107
}
2108
2108
2109
2109
for attr in krate_attrs {
2110
- if !attr. check_name ( " feature" ) {
2110
+ if !attr. check_name_symbol ( symbols :: feature) {
2111
2111
continue
2112
2112
}
2113
2113
@@ -2237,7 +2237,7 @@ fn maybe_stage_features(span_handler: &Handler, krate: &ast::Crate,
2237
2237
} ;
2238
2238
if !allow_features {
2239
2239
for attr in & krate. attrs {
2240
- if attr. check_name ( " feature" ) {
2240
+ if attr. check_name_symbol ( symbols :: feature) {
2241
2241
let release_channel = option_env ! ( "CFG_RELEASE_CHANNEL" ) . unwrap_or ( "(unknown)" ) ;
2242
2242
span_err ! ( span_handler, attr. span, E0554 ,
2243
2243
"#![feature] may not be used on the {} release channel" ,
0 commit comments