1
1
use clippy_config:: Conf ;
2
2
use clippy_config:: types:: InherentImplLintScope ;
3
3
use clippy_utils:: diagnostics:: span_lint_and_then;
4
- use clippy_utils:: is_lint_allowed ;
4
+ use clippy_utils:: fulfill_or_allowed ;
5
5
use rustc_data_structures:: fx:: FxHashMap ;
6
6
use rustc_hir:: def_id:: { LocalDefId , LocalModDefId } ;
7
7
use rustc_hir:: { Item , ItemKind , Node } ;
@@ -81,10 +81,10 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
81
81
for ( & id, impl_ids) in & impls. inherent_impls {
82
82
if impl_ids. len ( ) < 2
83
83
// Check for `#[allow]` on the type definition
84
- || is_lint_allowed (
84
+ || fulfill_or_allowed (
85
85
cx,
86
86
MULTIPLE_INHERENT_IMPL ,
87
- cx. tcx . local_def_id_to_hir_id ( id) ,
87
+ [ cx. tcx . local_def_id_to_hir_id ( id) ] ,
88
88
) {
89
89
continue ;
90
90
}
@@ -95,18 +95,8 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
95
95
let criterion = match self . scope {
96
96
InherentImplLintScope :: Module => Criterion :: Module ( cx. tcx . parent_module ( hir_id) ) ,
97
97
InherentImplLintScope :: File => {
98
- if let Node :: Item ( & Item {
99
- kind : ItemKind :: Impl ( _impl_id) ,
100
- span,
101
- ..
102
- } ) = cx. tcx . hir_node ( hir_id)
103
- {
104
- Criterion :: File ( cx. tcx . sess . source_map ( ) . lookup_source_file ( span. lo ( ) ) . name . clone ( ) )
105
- } else {
106
- // We know we are working on an impl, so the pattern matching can
107
- // not fail
108
- unreachable ! ( )
109
- }
98
+ let span = cx. tcx . hir_span ( hir_id) ;
99
+ Criterion :: File ( cx. tcx . sess . source_map ( ) . lookup_source_file ( span. lo ( ) ) . name . clone ( ) )
110
100
} ,
111
101
InherentImplLintScope :: Crate => Criterion :: Crate ,
112
102
} ;
@@ -168,7 +158,7 @@ fn get_impl_span(cx: &LateContext<'_>, id: LocalDefId) -> Option<Span> {
168
158
{
169
159
( !span. from_expansion ( )
170
160
&& impl_item. generics . params . is_empty ( )
171
- && !is_lint_allowed ( cx, MULTIPLE_INHERENT_IMPL , id ) )
161
+ && !fulfill_or_allowed ( cx, MULTIPLE_INHERENT_IMPL , [ id ] ) )
172
162
. then_some ( span)
173
163
} else {
174
164
None
0 commit comments