@@ -29,8 +29,6 @@ use traits::{self, Reveal, ObligationCause};
2929use ty:: { self , TyCtxt , TypeFoldable } ;
3030use syntax_pos:: DUMMY_SP ;
3131
32- use syntax:: ast;
33-
3432pub mod specialization_graph;
3533
3634/// Information pertinent to an overlapping impl error.
@@ -106,22 +104,23 @@ pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
106104}
107105
108106/// Given a selected impl described by `impl_data`, returns the
109- /// definition and substitions for the method with the name `name`,
110- /// and trait method substitutions `substs`, in that impl, a less
111- /// specialized impl, or the trait default, whichever applies.
112- pub fn find_method < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
113- name : ast:: Name ,
114- substs : & ' tcx Substs < ' tcx > ,
115- impl_data : & super :: VtableImplData < ' tcx , ( ) > )
116- -> ( DefId , & ' tcx Substs < ' tcx > )
117- {
107+ /// definition and substitions for the method with the name `name`
108+ /// the kind `kind`, and trait method substitutions `substs`, in
109+ /// that impl, a less specialized impl, or the trait default,
110+ /// whichever applies.
111+ pub fn find_associated_item < ' a , ' tcx > (
112+ tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
113+ item : & ty:: AssociatedItem ,
114+ substs : & ' tcx Substs < ' tcx > ,
115+ impl_data : & super :: VtableImplData < ' tcx , ( ) > ,
116+ ) -> ( DefId , & ' tcx Substs < ' tcx > ) {
118117 assert ! ( !substs. needs_infer( ) ) ;
119118
120119 let trait_def_id = tcx. trait_id_of_impl ( impl_data. impl_def_id ) . unwrap ( ) ;
121120 let trait_def = tcx. lookup_trait_def ( trait_def_id) ;
122121
123122 let ancestors = trait_def. ancestors ( impl_data. impl_def_id ) ;
124- match ancestors. defs ( tcx, name, ty :: AssociatedKind :: Method ) . next ( ) {
123+ match ancestors. defs ( tcx, item . name , item . kind ) . next ( ) {
125124 Some ( node_item) => {
126125 let substs = tcx. infer_ctxt ( ( ) , Reveal :: All ) . enter ( |infcx| {
127126 let substs = substs. rebase_onto ( tcx, trait_def_id, impl_data. substs ) ;
@@ -137,7 +136,7 @@ pub fn find_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
137136 ( node_item. item . def_id , substs)
138137 }
139138 None => {
140- bug ! ( "method {:?} not found in {:?}" , name , impl_data. impl_def_id)
139+ bug ! ( "{:?} not found in {:?}" , item , impl_data. impl_def_id)
141140 }
142141 }
143142}
0 commit comments