@@ -910,17 +910,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
910910 for ast_bound in ast_bounds {
911911 if let Some ( trait_ref) = ast_bound. trait_ref ( ) {
912912 if let Some ( trait_did) = trait_ref. trait_def_id ( ) {
913- if super_traits_of ( self . tcx ( ) , trait_did) . any ( |trait_did| {
914- self . tcx ( )
915- . associated_items ( trait_did)
916- . find_by_name_and_kind (
917- self . tcx ( ) ,
918- assoc_name,
919- ty:: AssocKind :: Type ,
920- trait_did,
921- )
922- . is_some ( )
923- } ) {
913+ if self . trait_may_define_assoc_type ( trait_did, assoc_name) {
924914 result. push ( ast_bound) ;
925915 }
926916 }
@@ -930,6 +920,17 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
930920 self . compute_bounds ( param_ty, & result, sized_by_default, span)
931921 }
932922
923+ /// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
924+ /// returns true if the `trait_def_id` defines an associated item of name `assoc_name`.
925+ fn trait_may_define_assoc_type ( & self , trait_def_id : DefId , assoc_name : Ident ) -> bool {
926+ super_traits_of ( self . tcx ( ) , trait_def_id) . any ( |trait_did| {
927+ self . tcx ( )
928+ . associated_items ( trait_did)
929+ . find_by_name_and_kind ( self . tcx ( ) , assoc_name, ty:: AssocKind :: Type , trait_did)
930+ . is_some ( )
931+ } )
932+ }
933+
933934 /// Given an HIR binding like `Item = Foo` or `Item: Foo`, pushes the corresponding predicates
934935 /// onto `bounds`.
935936 ///
0 commit comments