11//! checks for attributes
22
33use crate :: reexport:: * ;
4- use crate :: utils:: sym;
54use crate :: utils:: {
65 in_macro_or_desugar, is_present_in_source, last_line_of_span, match_def_path, paths, snippet_opt, span_lint,
76 span_lint_and_sugg, span_lint_and_then, without_block_comments,
@@ -18,7 +17,7 @@ use rustc_errors::Applicability;
1817use semver:: Version ;
1918use syntax:: ast:: { AttrStyle , Attribute , Lit , LitKind , MetaItemKind , NestedMetaItem } ;
2019use syntax:: source_map:: Span ;
21- use syntax :: symbol:: Symbol ;
20+ use syntax_pos :: symbol:: Symbol ;
2221
2322declare_clippy_lint ! {
2423 /// **What it does:** Checks for items annotated with `#[inline(always)]`,
@@ -207,14 +206,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
207206 } ,
208207 _ => { } ,
209208 }
210- if items. is_empty ( ) || !attr. check_name ( * sym:: deprecated) {
209+ if items. is_empty ( ) || !attr. check_name ( sym ! ( deprecated) ) {
211210 return ;
212211 }
213212 for item in items {
214213 if_chain ! {
215214 if let NestedMetaItem :: MetaItem ( mi) = & item;
216215 if let MetaItemKind :: NameValue ( lit) = & mi. node;
217- if mi. check_name( * sym:: since) ;
216+ if mi. check_name( sym! ( since) ) ;
218217 then {
219218 check_semver( cx, item. span( ) , lit) ;
220219 }
@@ -230,7 +229,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
230229 }
231230 match item. node {
232231 ItemKind :: ExternCrate ( ..) | ItemKind :: Use ( ..) => {
233- let skip_unused_imports = item. attrs . iter ( ) . any ( |attr| attr. check_name ( * sym:: macro_use) ) ;
232+ let skip_unused_imports = item. attrs . iter ( ) . any ( |attr| attr. check_name ( sym ! ( macro_use) ) ) ;
234233
235234 for attr in & item. attrs {
236235 if in_external_macro ( cx. sess ( ) , attr. span ) {
@@ -245,17 +244,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
245244 for lint in lint_list {
246245 match item. node {
247246 ItemKind :: Use ( ..) => {
248- if is_word ( lint, * sym:: unused_imports)
249- || is_word ( lint, * sym:: deprecated)
247+ if is_word ( lint, sym ! ( unused_imports) )
248+ || is_word ( lint, sym ! ( deprecated) )
250249 {
251250 return ;
252251 }
253252 } ,
254253 ItemKind :: ExternCrate ( ..) => {
255- if is_word ( lint, * sym:: unused_imports) && skip_unused_imports {
254+ if is_word ( lint, sym ! ( unused_imports) ) && skip_unused_imports {
256255 return ;
257256 }
258- if is_word ( lint, * sym:: unused_extern_crates) {
257+ if is_word ( lint, sym ! ( unused_extern_crates) ) {
259258 return ;
260259 }
261260 } ,
@@ -399,7 +398,7 @@ fn is_relevant_expr(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, exp
399398 ExprKind :: Call ( path_expr, _) => {
400399 if let ExprKind :: Path ( qpath) = & path_expr. node {
401400 if let Some ( fun_id) = tables. qpath_res ( qpath, path_expr. hir_id ) . opt_def_id ( ) {
402- !match_def_path ( cx, fun_id, & * paths:: BEGIN_PANIC )
401+ !match_def_path ( cx, fun_id, & paths:: BEGIN_PANIC )
403402 } else {
404403 true
405404 }
@@ -445,10 +444,10 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib
445444 }
446445
447446 if let Some ( values) = attr. meta_item_list ( ) {
448- if values. len ( ) != 1 || !attr. check_name ( * sym:: inline) {
447+ if values. len ( ) != 1 || !attr. check_name ( sym ! ( inline) ) {
449448 continue ;
450449 }
451- if is_word ( & values[ 0 ] , * sym:: always) {
450+ if is_word ( & values[ 0 ] , sym ! ( always) ) {
452451 span_lint (
453452 cx,
454453 INLINE_ALWAYS ,
@@ -491,16 +490,16 @@ impl EarlyLintPass for DeprecatedCfgAttribute {
491490 fn check_attribute ( & mut self , cx : & EarlyContext < ' _ > , attr : & Attribute ) {
492491 if_chain ! {
493492 // check cfg_attr
494- if attr. check_name( * sym:: cfg_attr) ;
493+ if attr. check_name( sym! ( cfg_attr) ) ;
495494 if let Some ( items) = attr. meta_item_list( ) ;
496495 if items. len( ) == 2 ;
497496 // check for `rustfmt`
498497 if let Some ( feature_item) = items[ 0 ] . meta_item( ) ;
499- if feature_item. check_name( * sym:: rustfmt) ;
498+ if feature_item. check_name( sym! ( rustfmt) ) ;
500499 // check for `rustfmt_skip` and `rustfmt::skip`
501500 if let Some ( skip_item) = & items[ 1 ] . meta_item( ) ;
502- if skip_item. check_name( * sym:: rustfmt_skip) ||
503- skip_item. path. segments. last( ) . expect( "empty path in attribute" ) . ident. name == * sym:: skip;
501+ if skip_item. check_name( sym! ( rustfmt_skip) ) ||
502+ skip_item. path. segments. last( ) . expect( "empty path in attribute" ) . ident. name == sym! ( skip) ;
504503 // Only lint outer attributes, because custom inner attributes are unstable
505504 // Tracking issue: https://github.com/rust-lang/rust/issues/54726
506505 if let AttrStyle :: Outer = attr. style;
0 commit comments