@@ -1309,14 +1309,15 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1309
1309
use crate :: ResolutionError :: * ;
1310
1310
match & item. kind {
1311
1311
AssocItemKind :: Const ( _default, _ty, _expr) => {
1312
- debug ! ( "resolve_implementation AssocItemKind::Const" , ) ;
1312
+ debug ! ( "resolve_implementation AssocItemKind::Const" ) ;
1313
1313
// If this is a trait impl, ensure the const
1314
1314
// exists in trait
1315
1315
this. check_trait_item (
1316
1316
item. ident ,
1317
+ & item. kind ,
1317
1318
ValueNS ,
1318
1319
item. span ,
1319
- |n , s| ConstNotMemberOfTrait ( n , s) ,
1320
+ |i , s, c | ConstNotMemberOfTrait ( i , s, c ) ,
1320
1321
) ;
1321
1322
1322
1323
// We allow arbitrary const expressions inside of associated consts,
@@ -1338,6 +1339,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1338
1339
) ;
1339
1340
}
1340
1341
AssocItemKind :: Fn ( box FnKind ( .., generics, _) ) => {
1342
+ debug ! ( "resolve_implementation AssocItemKind::Fn" ) ;
1341
1343
// We also need a new scope for the impl item type parameters.
1342
1344
this. with_generic_param_rib (
1343
1345
generics,
@@ -1347,9 +1349,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1347
1349
// exists in trait
1348
1350
this. check_trait_item (
1349
1351
item. ident ,
1352
+ & item. kind ,
1350
1353
ValueNS ,
1351
1354
item. span ,
1352
- |n , s| MethodNotMemberOfTrait ( n , s) ,
1355
+ |i , s, c | MethodNotMemberOfTrait ( i , s, c ) ,
1353
1356
) ;
1354
1357
1355
1358
visit:: walk_assoc_item (
@@ -1366,6 +1369,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1366
1369
_,
1367
1370
_,
1368
1371
) ) => {
1372
+ debug ! ( "resolve_implementation AssocItemKind::TyAlias" ) ;
1369
1373
// We also need a new scope for the impl item type parameters.
1370
1374
this. with_generic_param_rib (
1371
1375
generics,
@@ -1375,9 +1379,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1375
1379
// exists in trait
1376
1380
this. check_trait_item (
1377
1381
item. ident ,
1382
+ & item. kind ,
1378
1383
TypeNS ,
1379
1384
item. span ,
1380
- |n , s| TypeNotMemberOfTrait ( n , s) ,
1385
+ |i , s, c | TypeNotMemberOfTrait ( i , s, c ) ,
1381
1386
) ;
1382
1387
1383
1388
visit:: walk_assoc_item (
@@ -1401,9 +1406,15 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1401
1406
} ) ;
1402
1407
}
1403
1408
1404
- fn check_trait_item < F > ( & mut self , ident : Ident , ns : Namespace , span : Span , err : F )
1405
- where
1406
- F : FnOnce ( Symbol , & str ) -> ResolutionError < ' _ > ,
1409
+ fn check_trait_item < F > (
1410
+ & mut self ,
1411
+ ident : Ident ,
1412
+ kind : & AssocItemKind ,
1413
+ ns : Namespace ,
1414
+ span : Span ,
1415
+ err : F ,
1416
+ ) where
1417
+ F : FnOnce ( Ident , & str , Option < Symbol > ) -> ResolutionError < ' _ > ,
1407
1418
{
1408
1419
// If there is a TraitRef in scope for an impl, then the method must be in the
1409
1420
// trait.
@@ -1420,8 +1431,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1420
1431
)
1421
1432
. is_err ( )
1422
1433
{
1434
+ let candidate = self . find_similarly_named_assoc_item ( ident. name , kind) ;
1423
1435
let path = & self . current_trait_ref . as_ref ( ) . unwrap ( ) . 1 . path ;
1424
- self . report_error ( span, err ( ident. name , & path_names_to_string ( path) ) ) ;
1436
+ self . report_error ( span, err ( ident, & path_names_to_string ( path) , candidate ) ) ;
1425
1437
}
1426
1438
}
1427
1439
}
0 commit comments