@@ -12,6 +12,7 @@ use crate::hir;
12
12
use crate :: hir:: def_id:: DefId ;
13
13
use crate :: hir:: intravisit:: { self , Visitor , NestedVisitorMap } ;
14
14
use std:: fmt:: { self , Display } ;
15
+ use syntax:: symbol:: sym;
15
16
use syntax_pos:: Span ;
16
17
17
18
#[ derive( Copy , Clone , PartialEq ) ]
@@ -95,18 +96,18 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
95
96
fn check_attributes ( & self , item : & hir:: Item , target : Target ) {
96
97
if target == Target :: Fn || target == Target :: Const {
97
98
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) ) {
99
100
self . tcx . sess . struct_span_err ( a. span , "attribute should be applied to a function" )
100
101
. span_label ( item. span , "not a function" )
101
102
. emit ( ) ;
102
103
}
103
104
104
105
for attr in & item. attrs {
105
- if attr. check_name ( " inline" ) {
106
+ if attr. check_name ( sym :: inline) {
106
107
self . check_inline ( attr, & item. span , target)
107
- } else if attr. check_name ( " non_exhaustive" ) {
108
+ } else if attr. check_name ( sym :: non_exhaustive) {
108
109
self . check_non_exhaustive ( attr, item, target)
109
- } else if attr. check_name ( " marker" ) {
110
+ } else if attr. check_name ( sym :: marker) {
110
111
self . check_marker ( attr, item, target)
111
112
}
112
113
}
@@ -166,7 +167,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
166
167
// ```
167
168
let hints: Vec < _ > = item. attrs
168
169
. iter ( )
169
- . filter ( |attr| attr. check_name ( " repr" ) )
170
+ . filter ( |attr| attr. check_name ( sym :: repr) )
170
171
. filter_map ( |attr| attr. meta_item_list ( ) )
171
172
. flatten ( )
172
173
. collect ( ) ;
@@ -268,10 +269,10 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
268
269
// When checking statements ignore expressions, they will be checked later
269
270
if let hir:: StmtKind :: Local ( ref l) = stmt. node {
270
271
for attr in l. attrs . iter ( ) {
271
- if attr. check_name ( " inline" ) {
272
+ if attr. check_name ( sym :: inline) {
272
273
self . check_inline ( attr, & stmt. span , Target :: Statement ) ;
273
274
}
274
- if attr. check_name ( " repr" ) {
275
+ if attr. check_name ( sym :: repr) {
275
276
self . emit_repr_error (
276
277
attr. span ,
277
278
stmt. span ,
@@ -289,10 +290,10 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
289
290
_ => Target :: Expression ,
290
291
} ;
291
292
for attr in expr. attrs . iter ( ) {
292
- if attr. check_name ( " inline" ) {
293
+ if attr. check_name ( sym :: inline) {
293
294
self . check_inline ( attr, & expr. span , target) ;
294
295
}
295
- if attr. check_name ( " repr" ) {
296
+ if attr. check_name ( sym :: repr) {
296
297
self . emit_repr_error (
297
298
attr. span ,
298
299
expr. span ,
@@ -305,7 +306,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
305
306
306
307
fn check_used ( & self , item : & hir:: Item , target : Target ) {
307
308
for attr in & item. attrs {
308
- if attr. check_name ( " used" ) && target != Target :: Static {
309
+ if attr. check_name ( sym :: used) && target != Target :: Static {
309
310
self . tcx . sess
310
311
. span_err ( attr. span , "attribute must be applied to a `static` variable" ) ;
311
312
}
0 commit comments