@@ -1309,14 +1309,15 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13091309 use crate :: ResolutionError :: * ;
13101310 match & item. kind {
13111311 AssocItemKind :: Const ( _default, _ty, _expr) => {
1312- debug ! ( "resolve_implementation AssocItemKind::Const" , ) ;
1312+ debug ! ( "resolve_implementation AssocItemKind::Const" ) ;
13131313 // If this is a trait impl, ensure the const
13141314 // exists in trait
13151315 this. check_trait_item (
13161316 item. ident ,
1317+ & item. kind ,
13171318 ValueNS ,
13181319 item. span ,
1319- |n , s| ConstNotMemberOfTrait ( n , s) ,
1320+ |i , s, c | ConstNotMemberOfTrait ( i , s, c ) ,
13201321 ) ;
13211322
13221323 // We allow arbitrary const expressions inside of associated consts,
@@ -1338,6 +1339,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13381339 ) ;
13391340 }
13401341 AssocItemKind :: Fn ( box FnKind ( .., generics, _) ) => {
1342+ debug ! ( "resolve_implementation AssocItemKind::Fn" ) ;
13411343 // We also need a new scope for the impl item type parameters.
13421344 this. with_generic_param_rib (
13431345 generics,
@@ -1347,9 +1349,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13471349 // exists in trait
13481350 this. check_trait_item (
13491351 item. ident ,
1352+ & item. kind ,
13501353 ValueNS ,
13511354 item. span ,
1352- |n , s| MethodNotMemberOfTrait ( n , s) ,
1355+ |i , s, c | MethodNotMemberOfTrait ( i , s, c ) ,
13531356 ) ;
13541357
13551358 visit:: walk_assoc_item (
@@ -1366,6 +1369,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13661369 _,
13671370 _,
13681371 ) ) => {
1372+ debug ! ( "resolve_implementation AssocItemKind::TyAlias" ) ;
13691373 // We also need a new scope for the impl item type parameters.
13701374 this. with_generic_param_rib (
13711375 generics,
@@ -1375,9 +1379,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13751379 // exists in trait
13761380 this. check_trait_item (
13771381 item. ident ,
1382+ & item. kind ,
13781383 TypeNS ,
13791384 item. span ,
1380- |n , s| TypeNotMemberOfTrait ( n , s) ,
1385+ |i , s, c | TypeNotMemberOfTrait ( i , s, c ) ,
13811386 ) ;
13821387
13831388 visit:: walk_assoc_item (
@@ -1401,9 +1406,15 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
14011406 } ) ;
14021407 }
14031408
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 < ' _ > ,
14071418 {
14081419 // If there is a TraitRef in scope for an impl, then the method must be in the
14091420 // trait.
@@ -1420,8 +1431,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
14201431 )
14211432 . is_err ( )
14221433 {
1434+ let candidate = self . find_similarly_named_assoc_item ( ident. name , kind) ;
14231435 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 ) ) ;
14251437 }
14261438 }
14271439 }
0 commit comments