@@ -746,16 +746,9 @@ fn lookup_impl_assoc_item_for_trait_ref(
746
746
let table = InferenceTable :: new ( db, env) ;
747
747
748
748
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) ) ,
759
752
AssocItemId :: TypeAliasId ( _) => None ,
760
753
} ) ?;
761
754
Some ( ( item, impl_subst) )
@@ -850,7 +843,7 @@ fn is_inherent_impl_coherent(
850
843
} ;
851
844
rustc_has_incoherent_inherent_impls
852
845
&& !impl_data. items . is_empty ( )
853
- && impl_data. items . iter ( ) . copied ( ) . all ( |assoc| match assoc {
846
+ && impl_data. items . iter ( ) . all ( |& ( _ , assoc) | match assoc {
854
847
AssocItemId :: FunctionId ( it) => db. function_data ( it) . rustc_allow_incoherent_impl ,
855
848
AssocItemId :: ConstId ( it) => db. const_data ( it) . rustc_allow_incoherent_impl ,
856
849
AssocItemId :: TypeAliasId ( it) => db. type_alias_data ( it) . rustc_allow_incoherent_impl ,
@@ -1399,7 +1392,7 @@ fn iterate_inherent_methods(
1399
1392
callback : & mut dyn FnMut ( ReceiverAdjustments , AssocItemId , bool ) -> ControlFlow < ( ) > ,
1400
1393
) -> ControlFlow < ( ) > {
1401
1394
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 ( ) {
1403
1396
let visible = match is_valid_impl_method_candidate (
1404
1397
table,
1405
1398
self_ty,
@@ -1408,6 +1401,7 @@ fn iterate_inherent_methods(
1408
1401
name,
1409
1402
impl_id,
1410
1403
item,
1404
+ item_name,
1411
1405
) {
1412
1406
IsValidCandidate :: Yes => true ,
1413
1407
IsValidCandidate :: NotVisible => false ,
@@ -1467,6 +1461,7 @@ fn is_valid_impl_method_candidate(
1467
1461
name : Option < & Name > ,
1468
1462
impl_id : ImplId ,
1469
1463
item : AssocItemId ,
1464
+ item_name : & Name ,
1470
1465
) -> IsValidCandidate {
1471
1466
match item {
1472
1467
AssocItemId :: FunctionId ( f) => is_valid_impl_fn_candidate (
@@ -1477,11 +1472,12 @@ fn is_valid_impl_method_candidate(
1477
1472
receiver_ty,
1478
1473
self_ty,
1479
1474
visible_from_module,
1475
+ item_name,
1480
1476
) ,
1481
1477
AssocItemId :: ConstId ( c) => {
1482
1478
let db = table. db ;
1483
1479
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 ) ) ;
1485
1481
1486
1482
if let Some ( from_module) = visible_from_module {
1487
1483
if !db. const_visibility ( c) . is_visible_from ( db. upcast ( ) , from_module) {
@@ -1565,11 +1561,13 @@ fn is_valid_impl_fn_candidate(
1565
1561
receiver_ty : Option < & Ty > ,
1566
1562
self_ty : & Ty ,
1567
1563
visible_from_module : Option < ModuleId > ,
1564
+ item_name : & Name ,
1568
1565
) -> IsValidCandidate {
1566
+ check_that ! ( name. is_none_or( |n| n == item_name) ) ;
1567
+
1569
1568
let db = table. db ;
1570
1569
let data = db. function_data ( fn_id) ;
1571
1570
1572
- check_that ! ( name. is_none_or( |n| n == & data. name) ) ;
1573
1571
if let Some ( from_module) = visible_from_module {
1574
1572
if !db. function_visibility ( fn_id) . is_visible_from ( db. upcast ( ) , from_module) {
1575
1573
cov_mark:: hit!( autoderef_candidate_not_visible) ;
0 commit comments