@@ -71,8 +71,9 @@ declare_clippy_lint! {
71
71
/// **What it does:** Checks for `extern crate` and `use` items annotated with
72
72
/// lint attributes.
73
73
///
74
- /// This lint permits `#[allow(unused_imports)]`, `#[allow(deprecated)]` and
75
- /// `#[allow(unreachable_pub)]` on `use` items and `#[allow(unused_imports)]` on
74
+ /// This lint permits `#[allow(unused_imports)]`, `#[allow(deprecated)]`,
75
+ /// `#[allow(unreachable_pub)]`, `#[allow(clippy::wildcard_imports)]` and
76
+ /// `#[allow(clippy::enum_glob_use)]` on `use` items and `#[allow(unused_imports)]` on
76
77
/// `extern crate` items with a `#[macro_use]` attribute.
77
78
///
78
79
/// **Why is this bad?** Lint attributes have no effect on crate imports. Most
@@ -318,7 +319,8 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
318
319
if let Some ( ident) = attr. ident ( ) {
319
320
match & * ident. as_str ( ) {
320
321
"allow" | "warn" | "deny" | "forbid" => {
321
- // permit `unused_imports`, `deprecated` and `unreachable_pub` for `use` items
322
+ // permit `unused_imports`, `deprecated`, `unreachable_pub`,
323
+ // `clippy::wildcard_imports`, and `clippy::enum_glob_use` for `use` items
322
324
// and `unused_imports` for `extern crate` items with `macro_use`
323
325
for lint in lint_list {
324
326
match item. kind {
@@ -327,6 +329,9 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
327
329
|| is_word ( lint, sym ! ( deprecated) )
328
330
|| is_word ( lint, sym ! ( unreachable_pub) )
329
331
|| is_word ( lint, sym ! ( unused) )
332
+ || extract_clippy_lint ( lint)
333
+ . map_or ( false , |s| s == "wildcard_imports" )
334
+ || extract_clippy_lint ( lint) . map_or ( false , |s| s == "enum_glob_use" )
330
335
{
331
336
return ;
332
337
}
@@ -387,24 +392,25 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
387
392
}
388
393
}
389
394
390
- fn check_clippy_lint_names ( cx : & LateContext < ' _ > , ident : & str , items : & [ NestedMetaItem ] ) {
391
- fn extract_name ( lint : & NestedMetaItem ) -> Option < SymbolStr > {
392
- if_chain ! {
393
- if let Some ( meta_item) = lint. meta_item( ) ;
394
- if meta_item. path. segments. len( ) > 1 ;
395
- if let tool_name = meta_item. path. segments[ 0 ] . ident;
396
- if tool_name. as_str( ) == "clippy" ;
397
- let lint_name = meta_item. path. segments. last( ) . unwrap( ) . ident. name;
398
- then {
399
- return Some ( lint_name. as_str( ) ) ;
400
- }
395
+ /// Returns the lint name if it is clippy lint.
396
+ fn extract_clippy_lint ( lint : & NestedMetaItem ) -> Option < SymbolStr > {
397
+ if_chain ! {
398
+ if let Some ( meta_item) = lint. meta_item( ) ;
399
+ if meta_item. path. segments. len( ) > 1 ;
400
+ if let tool_name = meta_item. path. segments[ 0 ] . ident;
401
+ if tool_name. as_str( ) == "clippy" ;
402
+ let lint_name = meta_item. path. segments. last( ) . unwrap( ) . ident. name;
403
+ then {
404
+ return Some ( lint_name. as_str( ) ) ;
401
405
}
402
- None
403
406
}
407
+ None
408
+ }
404
409
410
+ fn check_clippy_lint_names ( cx : & LateContext < ' _ > , ident : & str , items : & [ NestedMetaItem ] ) {
405
411
let lint_store = cx. lints ( ) ;
406
412
for lint in items {
407
- if let Some ( lint_name) = extract_name ( lint) {
413
+ if let Some ( lint_name) = extract_clippy_lint ( lint) {
408
414
if let CheckLintNameResult :: Tool ( Err ( ( None , _) ) ) =
409
415
lint_store. check_lint_name ( & lint_name, Some ( sym ! ( clippy) ) )
410
416
{
0 commit comments