11use clippy_config:: Conf ;
22use clippy_config:: types:: InherentImplLintScope ;
33use clippy_utils:: diagnostics:: span_lint_and_then;
4- use clippy_utils:: is_lint_allowed ;
4+ use clippy_utils:: fulfill_or_allowed ;
55use rustc_data_structures:: fx:: FxHashMap ;
66use rustc_hir:: def_id:: { LocalDefId , LocalModDefId } ;
77use rustc_hir:: { Item , ItemKind , Node } ;
@@ -81,10 +81,10 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
8181 for ( & id, impl_ids) in & impls. inherent_impls {
8282 if impl_ids. len ( ) < 2
8383 // Check for `#[allow]` on the type definition
84- || is_lint_allowed (
84+ || fulfill_or_allowed (
8585 cx,
8686 MULTIPLE_INHERENT_IMPL ,
87- cx. tcx . local_def_id_to_hir_id ( id) ,
87+ [ cx. tcx . local_def_id_to_hir_id ( id) ] ,
8888 ) {
8989 continue ;
9090 }
@@ -95,18 +95,8 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
9595 let criterion = match self . scope {
9696 InherentImplLintScope :: Module => Criterion :: Module ( cx. tcx . parent_module ( hir_id) ) ,
9797 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 ( ) )
110100 } ,
111101 InherentImplLintScope :: Crate => Criterion :: Crate ,
112102 } ;
@@ -168,7 +158,7 @@ fn get_impl_span(cx: &LateContext<'_>, id: LocalDefId) -> Option<Span> {
168158 {
169159 ( !span. from_expansion ( )
170160 && impl_item. generics . params . is_empty ( )
171- && !is_lint_allowed ( cx, MULTIPLE_INHERENT_IMPL , id ) )
161+ && !fulfill_or_allowed ( cx, MULTIPLE_INHERENT_IMPL , [ id ] ) )
172162 . then_some ( span)
173163 } else {
174164 None
0 commit comments