@@ -82,6 +82,9 @@ pub trait AstConv<'tcx> {
82
82
fn get_type_parameter_bounds ( & self , span : Span , def_id : ast:: NodeId )
83
83
-> Result < Vec < ty:: PolyTraitRef < ' tcx > > , ErrorReported > ;
84
84
85
+ fn trait_defines_associated_type_named ( & self , trait_def_id : ast:: DefId , name : ast:: Name )
86
+ -> bool ;
87
+
85
88
/// Return an (optional) substitution to convert bound type parameters that
86
89
/// are in scope into free ones. This function should only return Some
87
90
/// within a fn body.
@@ -783,7 +786,7 @@ fn ast_type_binding_to_projection_predicate<'tcx>(
783
786
// We want to produce `<B as SuperTrait<int>>::T == foo`.
784
787
785
788
// Simple case: X is defined in the current trait.
786
- if trait_defines_associated_type_named ( this , trait_ref. def_id , binding. item_name ) {
789
+ if this . trait_defines_associated_type_named ( trait_ref. def_id , binding. item_name ) {
787
790
return Ok ( ty:: ProjectionPredicate {
788
791
projection_ty : ty:: ProjectionTy {
789
792
trait_ref : trait_ref,
@@ -812,7 +815,7 @@ fn ast_type_binding_to_projection_predicate<'tcx>(
812
815
813
816
let mut candidates: Vec < ty:: PolyTraitRef > =
814
817
traits:: supertraits ( tcx, trait_ref. to_poly_trait_ref ( ) )
815
- . filter ( |r| trait_defines_associated_type_named ( this , r. def_id ( ) , binding. item_name ) )
818
+ . filter ( |r| this . trait_defines_associated_type_named ( r. def_id ( ) , binding. item_name ) )
816
819
. collect ( ) ;
817
820
818
821
// If converting for an object type, then remove the dummy-ty from `Self` now.
@@ -1036,7 +1039,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
1036
1039
1037
1040
let mut suitable_bounds: Vec < _ > =
1038
1041
traits:: transitive_bounds ( tcx, & bounds)
1039
- . filter ( |b| trait_defines_associated_type_named ( this , b. def_id ( ) , assoc_name) )
1042
+ . filter ( |b| this . trait_defines_associated_type_named ( b. def_id ( ) , assoc_name) )
1040
1043
. collect ( ) ;
1041
1044
1042
1045
if suitable_bounds. len ( ) == 0 {
@@ -1090,16 +1093,6 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
1090
1093
( ty, def:: DefAssociatedTy ( trait_did, item_did) )
1091
1094
}
1092
1095
1093
- fn trait_defines_associated_type_named ( this : & AstConv ,
1094
- trait_def_id : ast:: DefId ,
1095
- assoc_name : ast:: Name )
1096
- -> bool
1097
- {
1098
- let tcx = this. tcx ( ) ;
1099
- let trait_def = ty:: lookup_trait_def ( tcx, trait_def_id) ;
1100
- trait_def. associated_type_names . contains ( & assoc_name)
1101
- }
1102
-
1103
1096
fn qpath_to_ty < ' tcx > ( this : & AstConv < ' tcx > ,
1104
1097
rscope : & RegionScope ,
1105
1098
span : Span ,
0 commit comments