@@ -746,16 +746,9 @@ fn lookup_impl_assoc_item_for_trait_ref(
746746 let table = InferenceTable :: new ( db, env) ;
747747
748748 let ( impl_data, impl_subst) = find_matching_impl ( impls, table, trait_ref) ?;
749- let item = impl_data. items . iter ( ) . find_map ( |& it| match it {
750- AssocItemId :: FunctionId ( f) => {
751- ( db. function_data ( f) . name == * name) . then_some ( AssocItemId :: FunctionId ( f) )
752- }
753- AssocItemId :: ConstId ( c) => db
754- . const_data ( c)
755- . name
756- . as_ref ( )
757- . map ( |n| n == name)
758- . and_then ( |result| if result { Some ( AssocItemId :: ConstId ( c) ) } else { None } ) ,
749+ let item = impl_data. items . iter ( ) . find_map ( |( n, it) | match * it {
750+ AssocItemId :: FunctionId ( f) => ( n == name) . then_some ( AssocItemId :: FunctionId ( f) ) ,
751+ AssocItemId :: ConstId ( c) => ( n == name) . then_some ( AssocItemId :: ConstId ( c) ) ,
759752 AssocItemId :: TypeAliasId ( _) => None ,
760753 } ) ?;
761754 Some ( ( item, impl_subst) )
@@ -850,7 +843,7 @@ fn is_inherent_impl_coherent(
850843 } ;
851844 rustc_has_incoherent_inherent_impls
852845 && !impl_data. items . is_empty ( )
853- && impl_data. items . iter ( ) . copied ( ) . all ( |assoc| match assoc {
846+ && impl_data. items . iter ( ) . all ( |& ( _ , assoc) | match assoc {
854847 AssocItemId :: FunctionId ( it) => db. function_data ( it) . rustc_allow_incoherent_impl ,
855848 AssocItemId :: ConstId ( it) => db. const_data ( it) . rustc_allow_incoherent_impl ,
856849 AssocItemId :: TypeAliasId ( it) => db. type_alias_data ( it) . rustc_allow_incoherent_impl ,
@@ -1399,7 +1392,7 @@ fn iterate_inherent_methods(
13991392 callback : & mut dyn FnMut ( ReceiverAdjustments , AssocItemId , bool ) -> ControlFlow < ( ) > ,
14001393 ) -> ControlFlow < ( ) > {
14011394 for & impl_id in impls. for_self_ty ( self_ty) {
1402- for & item in table. db . impl_data ( impl_id) . items . iter ( ) {
1395+ for & ( ref item_name , item) in table. db . impl_data ( impl_id) . items . iter ( ) {
14031396 let visible = match is_valid_impl_method_candidate (
14041397 table,
14051398 self_ty,
@@ -1408,6 +1401,7 @@ fn iterate_inherent_methods(
14081401 name,
14091402 impl_id,
14101403 item,
1404+ item_name,
14111405 ) {
14121406 IsValidCandidate :: Yes => true ,
14131407 IsValidCandidate :: NotVisible => false ,
@@ -1467,6 +1461,7 @@ fn is_valid_impl_method_candidate(
14671461 name : Option < & Name > ,
14681462 impl_id : ImplId ,
14691463 item : AssocItemId ,
1464+ item_name : & Name ,
14701465) -> IsValidCandidate {
14711466 match item {
14721467 AssocItemId :: FunctionId ( f) => is_valid_impl_fn_candidate (
@@ -1477,11 +1472,12 @@ fn is_valid_impl_method_candidate(
14771472 receiver_ty,
14781473 self_ty,
14791474 visible_from_module,
1475+ item_name,
14801476 ) ,
14811477 AssocItemId :: ConstId ( c) => {
14821478 let db = table. db ;
14831479 check_that ! ( receiver_ty. is_none( ) ) ;
1484- check_that ! ( name. is_none_or( |n| db . const_data ( c ) . name . as_ref ( ) == Some ( n ) ) ) ;
1480+ check_that ! ( name. is_none_or( |n| n == item_name ) ) ;
14851481
14861482 if let Some ( from_module) = visible_from_module {
14871483 if !db. const_visibility ( c) . is_visible_from ( db. upcast ( ) , from_module) {
@@ -1565,11 +1561,13 @@ fn is_valid_impl_fn_candidate(
15651561 receiver_ty : Option < & Ty > ,
15661562 self_ty : & Ty ,
15671563 visible_from_module : Option < ModuleId > ,
1564+ item_name : & Name ,
15681565) -> IsValidCandidate {
1566+ check_that ! ( name. is_none_or( |n| n == item_name) ) ;
1567+
15691568 let db = table. db ;
15701569 let data = db. function_data ( fn_id) ;
15711570
1572- check_that ! ( name. is_none_or( |n| n == & data. name) ) ;
15731571 if let Some ( from_module) = visible_from_module {
15741572 if !db. function_visibility ( fn_id) . is_visible_from ( db. upcast ( ) , from_module) {
15751573 cov_mark:: hit!( autoderef_candidate_not_visible) ;
0 commit comments