File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -75,13 +75,18 @@ fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>
7575
7676/// Returns the lint name if it is clippy lint.
7777pub ( super ) fn extract_clippy_lint ( lint : & MetaItemInner ) -> Option < Symbol > {
78- if let Some ( meta_item) = lint. meta_item ( )
79- && meta_item. path . segments . len ( ) > 1
80- && let tool_name = meta_item. path . segments [ 0 ] . ident
81- && tool_name. name == sym:: clippy
82- {
83- let lint_name = meta_item. path . segments . last ( ) . unwrap ( ) . ident . name ;
84- return Some ( lint_name) ;
78+ match namespace_and_lint ( lint) {
79+ ( Some ( sym:: clippy) , name) => name,
80+ _ => None ,
81+ }
82+ }
83+
84+ /// Returns the lint namespace, if any, as well as the lint name. (`None`, `None`) means
85+ /// the lint had less than 1 or more than 2 segments.
86+ pub ( super ) fn namespace_and_lint ( lint : & MetaItemInner ) -> ( Option < Symbol > , Option < Symbol > ) {
87+ match lint. meta_item ( ) . map ( |m| m. path . segments . as_slice ( ) ) . unwrap_or_default ( ) {
88+ [ name] => ( None , Some ( name. ident . name ) ) ,
89+ [ namespace, name] => ( Some ( namespace. ident . name ) , Some ( name. ident . name ) ) ,
90+ _ => ( None , None ) ,
8591 }
86- None
8792}
You can’t perform that action at this time.
0 commit comments