1
1
//! checks for attributes
2
2
3
3
use crate :: reexport:: * ;
4
- use crate :: utils:: sym;
5
4
use crate :: utils:: {
6
5
in_macro_or_desugar, is_present_in_source, last_line_of_span, match_def_path, paths, snippet_opt, span_lint,
7
6
span_lint_and_sugg, span_lint_and_then, without_block_comments,
@@ -18,7 +17,7 @@ use rustc_errors::Applicability;
18
17
use semver:: Version ;
19
18
use syntax:: ast:: { AttrStyle , Attribute , Lit , LitKind , MetaItemKind , NestedMetaItem } ;
20
19
use syntax:: source_map:: Span ;
21
- use syntax :: symbol:: Symbol ;
20
+ use syntax_pos :: symbol:: Symbol ;
22
21
23
22
declare_clippy_lint ! {
24
23
/// **What it does:** Checks for items annotated with `#[inline(always)]`,
@@ -207,14 +206,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
207
206
} ,
208
207
_ => { } ,
209
208
}
210
- if items. is_empty ( ) || !attr. check_name ( * sym:: deprecated) {
209
+ if items. is_empty ( ) || !attr. check_name ( sym ! ( deprecated) ) {
211
210
return ;
212
211
}
213
212
for item in items {
214
213
if_chain ! {
215
214
if let NestedMetaItem :: MetaItem ( mi) = & item;
216
215
if let MetaItemKind :: NameValue ( lit) = & mi. node;
217
- if mi. check_name( * sym:: since) ;
216
+ if mi. check_name( sym! ( since) ) ;
218
217
then {
219
218
check_semver( cx, item. span( ) , lit) ;
220
219
}
@@ -230,7 +229,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
230
229
}
231
230
match item. node {
232
231
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) ) ) ;
234
233
235
234
for attr in & item. attrs {
236
235
if in_external_macro ( cx. sess ( ) , attr. span ) {
@@ -245,17 +244,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
245
244
for lint in lint_list {
246
245
match item. node {
247
246
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) )
250
249
{
251
250
return ;
252
251
}
253
252
} ,
254
253
ItemKind :: ExternCrate ( ..) => {
255
- if is_word ( lint, * sym:: unused_imports) && skip_unused_imports {
254
+ if is_word ( lint, sym ! ( unused_imports) ) && skip_unused_imports {
256
255
return ;
257
256
}
258
- if is_word ( lint, * sym:: unused_extern_crates) {
257
+ if is_word ( lint, sym ! ( unused_extern_crates) ) {
259
258
return ;
260
259
}
261
260
} ,
@@ -399,7 +398,7 @@ fn is_relevant_expr(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, exp
399
398
ExprKind :: Call ( path_expr, _) => {
400
399
if let ExprKind :: Path ( qpath) = & path_expr. node {
401
400
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 )
403
402
} else {
404
403
true
405
404
}
@@ -445,10 +444,10 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib
445
444
}
446
445
447
446
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) ) {
449
448
continue ;
450
449
}
451
- if is_word ( & values[ 0 ] , * sym:: always) {
450
+ if is_word ( & values[ 0 ] , sym ! ( always) ) {
452
451
span_lint (
453
452
cx,
454
453
INLINE_ALWAYS ,
@@ -491,16 +490,16 @@ impl EarlyLintPass for DeprecatedCfgAttribute {
491
490
fn check_attribute ( & mut self , cx : & EarlyContext < ' _ > , attr : & Attribute ) {
492
491
if_chain ! {
493
492
// check cfg_attr
494
- if attr. check_name( * sym:: cfg_attr) ;
493
+ if attr. check_name( sym! ( cfg_attr) ) ;
495
494
if let Some ( items) = attr. meta_item_list( ) ;
496
495
if items. len( ) == 2 ;
497
496
// check for `rustfmt`
498
497
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) ) ;
500
499
// check for `rustfmt_skip` and `rustfmt::skip`
501
500
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) ;
504
503
// Only lint outer attributes, because custom inner attributes are unstable
505
504
// Tracking issue: https://github.com/rust-lang/rust/issues/54726
506
505
if let AttrStyle :: Outer = attr. style;
0 commit comments