@@ -71,8 +71,9 @@ declare_clippy_lint! {
7171 /// **What it does:** Checks for `extern crate` and `use` items annotated with
7272 /// lint attributes.
7373 ///
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
7677 /// `extern crate` items with a `#[macro_use]` attribute.
7778 ///
7879 /// **Why is this bad?** Lint attributes have no effect on crate imports. Most
@@ -318,7 +319,8 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
318319 if let Some ( ident) = attr. ident ( ) {
319320 match & * ident. as_str ( ) {
320321 "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
322324 // and `unused_imports` for `extern crate` items with `macro_use`
323325 for lint in lint_list {
324326 match item. kind {
@@ -327,6 +329,9 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
327329 || is_word ( lint, sym ! ( deprecated) )
328330 || is_word ( lint, sym ! ( unreachable_pub) )
329331 || 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" )
330335 {
331336 return ;
332337 }
@@ -387,24 +392,25 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
387392 }
388393}
389394
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( ) ) ;
401405 }
402- None
403406 }
407+ None
408+ }
404409
410+ fn check_clippy_lint_names ( cx : & LateContext < ' _ > , ident : & str , items : & [ NestedMetaItem ] ) {
405411 let lint_store = cx. lints ( ) ;
406412 for lint in items {
407- if let Some ( lint_name) = extract_name ( lint) {
413+ if let Some ( lint_name) = extract_clippy_lint ( lint) {
408414 if let CheckLintNameResult :: Tool ( Err ( ( None , _) ) ) =
409415 lint_store. check_lint_name ( & lint_name, Some ( sym ! ( clippy) ) )
410416 {
0 commit comments