@@ -12,6 +12,7 @@ use crate::hir;
1212use crate :: hir:: def_id:: DefId ;
1313use crate :: hir:: intravisit:: { self , Visitor , NestedVisitorMap } ;
1414use std:: fmt:: { self , Display } ;
15+ use syntax:: symbol:: sym;
1516use syntax_pos:: Span ;
1617
1718#[ derive( Copy , Clone , PartialEq ) ]
@@ -95,18 +96,18 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
9596 fn check_attributes ( & self , item : & hir:: Item , target : Target ) {
9697 if target == Target :: Fn || target == Target :: Const {
9798 self . tcx . codegen_fn_attrs ( self . tcx . hir ( ) . local_def_id_from_hir_id ( item. hir_id ) ) ;
98- } else if let Some ( a) = item. attrs . iter ( ) . find ( |a| a. check_name ( " target_feature" ) ) {
99+ } else if let Some ( a) = item. attrs . iter ( ) . find ( |a| a. check_name ( sym :: target_feature) ) {
99100 self . tcx . sess . struct_span_err ( a. span , "attribute should be applied to a function" )
100101 . span_label ( item. span , "not a function" )
101102 . emit ( ) ;
102103 }
103104
104105 for attr in & item. attrs {
105- if attr. check_name ( " inline" ) {
106+ if attr. check_name ( sym :: inline) {
106107 self . check_inline ( attr, & item. span , target)
107- } else if attr. check_name ( " non_exhaustive" ) {
108+ } else if attr. check_name ( sym :: non_exhaustive) {
108109 self . check_non_exhaustive ( attr, item, target)
109- } else if attr. check_name ( " marker" ) {
110+ } else if attr. check_name ( sym :: marker) {
110111 self . check_marker ( attr, item, target)
111112 }
112113 }
@@ -166,7 +167,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
166167 // ```
167168 let hints: Vec < _ > = item. attrs
168169 . iter ( )
169- . filter ( |attr| attr. check_name ( " repr" ) )
170+ . filter ( |attr| attr. check_name ( sym :: repr) )
170171 . filter_map ( |attr| attr. meta_item_list ( ) )
171172 . flatten ( )
172173 . collect ( ) ;
@@ -268,10 +269,10 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
268269 // When checking statements ignore expressions, they will be checked later
269270 if let hir:: StmtKind :: Local ( ref l) = stmt. node {
270271 for attr in l. attrs . iter ( ) {
271- if attr. check_name ( " inline" ) {
272+ if attr. check_name ( sym :: inline) {
272273 self . check_inline ( attr, & stmt. span , Target :: Statement ) ;
273274 }
274- if attr. check_name ( " repr" ) {
275+ if attr. check_name ( sym :: repr) {
275276 self . emit_repr_error (
276277 attr. span ,
277278 stmt. span ,
@@ -289,10 +290,10 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
289290 _ => Target :: Expression ,
290291 } ;
291292 for attr in expr. attrs . iter ( ) {
292- if attr. check_name ( " inline" ) {
293+ if attr. check_name ( sym :: inline) {
293294 self . check_inline ( attr, & expr. span , target) ;
294295 }
295- if attr. check_name ( " repr" ) {
296+ if attr. check_name ( sym :: repr) {
296297 self . emit_repr_error (
297298 attr. span ,
298299 expr. span ,
@@ -305,7 +306,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
305306
306307 fn check_used ( & self , item : & hir:: Item , target : Target ) {
307308 for attr in & item. attrs {
308- if attr. check_name ( " used" ) && target != Target :: Static {
309+ if attr. check_name ( sym :: used) && target != Target :: Static {
309310 self . tcx . sess
310311 . span_err ( attr. span , "attribute must be applied to a `static` variable" ) ;
311312 }
0 commit comments