@@ -154,14 +154,14 @@ impl<'a> Ctx<'a> {
154
154
let parent = path. syntax ( ) . parent ( ) ?;
155
155
if let Some ( parent) = ast:: Path :: cast ( parent. clone ( ) ) {
156
156
// Path inside path means that there is an associated
157
- // type on the type parameter. It is necessary to fully
158
- // qualify the type with `as Trait`. Even though it
159
- // might be unnecessary if `subst` is generic type,
160
- // always fully qualifying the path is safer because of
161
- // potential clash of associated types from multiple
162
- // traits
157
+ // type/constant on the type parameter. It is necessary
158
+ // to fully qualify the type with `as Trait`. Even
159
+ // though it might be unnecessary if `subst` is generic
160
+ // type, always fully qualifying the path is safer
161
+ // because of potential clash of associated types from
162
+ // multiple traits
163
163
164
- let trait_ref = find_trait_for_assoc_type (
164
+ let trait_ref = find_trait_for_assoc_item (
165
165
self . source_scope ,
166
166
tp,
167
167
parent. segment ( ) ?. name_ref ( ) ?,
@@ -252,24 +252,25 @@ fn get_type_args_from_arg_list(generic_arg_list: ast::GenericArgList) -> Option<
252
252
Some ( result)
253
253
}
254
254
255
- fn find_trait_for_assoc_type (
255
+ fn find_trait_for_assoc_item (
256
256
scope : & SemanticsScope ,
257
257
type_param : hir:: TypeParam ,
258
- assoc_type : ast:: NameRef ,
258
+ assoc_item : ast:: NameRef ,
259
259
) -> Option < hir:: Trait > {
260
260
let db = scope. db ;
261
261
let trait_bounds = type_param. trait_bounds ( db) ;
262
262
263
- let assoc_type_name = assoc_type . text ( ) ;
263
+ let assoc_item_name = assoc_item . text ( ) ;
264
264
265
265
for trait_ in trait_bounds {
266
- let type_aliases = trait_. items ( db) . into_iter ( ) . filter_map ( |item| match item {
267
- hir:: AssocItem :: TypeAlias ( ta) => Some ( ta) ,
266
+ let names = trait_. items ( db) . into_iter ( ) . filter_map ( |item| match item {
267
+ hir:: AssocItem :: TypeAlias ( ta) => Some ( ta. name ( db) ) ,
268
+ hir:: AssocItem :: Const ( cst) => cst. name ( db) ,
268
269
_ => None ,
269
270
} ) ;
270
271
271
- for type_alias in type_aliases {
272
- if assoc_type_name . as_str ( ) == type_alias . name ( db ) . as_text ( ) ?. as_str ( ) {
272
+ for name in names {
273
+ if assoc_item_name . as_str ( ) == name. as_text ( ) ?. as_str ( ) {
273
274
// It is fine to return the first match because in case of
274
275
// multiple possibilities, the exact trait must be disambiguated
275
276
// in the definition of trait being implemented, so this search
0 commit comments