@@ -24,7 +24,7 @@ use std::fmt;
24
24
25
25
use base_db:: { AnchoredPathBuf , FileId , FileRange } ;
26
26
use either:: Either ;
27
- use hir:: { AsAssocItem , FieldSource , HasSource , InFile , ModuleSource , Semantics } ;
27
+ use hir:: { FieldSource , HasSource , InFile , ModuleSource , Semantics } ;
28
28
use stdx:: never;
29
29
use syntax:: {
30
30
ast:: { self , HasName } ,
@@ -37,6 +37,7 @@ use crate::{
37
37
search:: FileReference ,
38
38
source_change:: { FileSystemEdit , SourceChange } ,
39
39
syntax_helpers:: node_ext:: expr_as_name_ref,
40
+ traits:: convert_to_def_in_trait,
40
41
RootDatabase ,
41
42
} ;
42
43
@@ -271,7 +272,7 @@ fn rename_reference(
271
272
}
272
273
}
273
274
274
- let def = convert_to_def_in_trait ( def , sema ) ;
275
+ let def = convert_to_def_in_trait ( sema . db , def ) ;
275
276
let usages = def. usages ( sema) . all ( ) ;
276
277
277
278
if !usages. is_empty ( ) && ident_kind == IdentifierKind :: Underscore {
@@ -298,47 +299,6 @@ fn rename_reference(
298
299
Ok ( source_change)
299
300
}
300
301
301
- pub ( crate ) fn convert_to_def_in_trait (
302
- def : Definition ,
303
- sema : & Semantics < RootDatabase > ,
304
- ) -> Definition {
305
- // HACK: resolve trait impl items to the item def of the trait definition
306
- // so that we properly resolve all trait item references
307
- let assoc_item = match def {
308
- Definition :: Function ( it) => it. as_assoc_item ( sema. db ) ,
309
- Definition :: TypeAlias ( it) => it. as_assoc_item ( sema. db ) ,
310
- Definition :: Const ( it) => it. as_assoc_item ( sema. db ) ,
311
- _ => None ,
312
- } ;
313
- match assoc_item {
314
- Some ( assoc) => assoc
315
- . containing_trait_impl ( sema. db )
316
- . and_then ( |trait_| {
317
- trait_. items ( sema. db ) . into_iter ( ) . find_map ( |it| match ( it, assoc) {
318
- ( hir:: AssocItem :: Function ( trait_func) , hir:: AssocItem :: Function ( func) )
319
- if trait_func. name ( sema. db ) == func. name ( sema. db ) =>
320
- {
321
- Some ( Definition :: Function ( trait_func) )
322
- }
323
- ( hir:: AssocItem :: Const ( trait_konst) , hir:: AssocItem :: Const ( konst) )
324
- if trait_konst. name ( sema. db ) == konst. name ( sema. db ) =>
325
- {
326
- Some ( Definition :: Const ( trait_konst) )
327
- }
328
- (
329
- hir:: AssocItem :: TypeAlias ( trait_type_alias) ,
330
- hir:: AssocItem :: TypeAlias ( type_alias) ,
331
- ) if trait_type_alias. name ( sema. db ) == type_alias. name ( sema. db ) => {
332
- Some ( Definition :: TypeAlias ( trait_type_alias) )
333
- }
334
- _ => None ,
335
- } )
336
- } )
337
- . unwrap_or ( def) ,
338
- None => def,
339
- }
340
- }
341
-
342
302
pub fn source_edit_from_references (
343
303
references : & [ FileReference ] ,
344
304
def : Definition ,
0 commit comments