@@ -244,14 +244,14 @@ impl Definition {
244
244
DefWithBody :: Variant ( v) => v. source ( db) . map ( |src| src. syntax ( ) . cloned ( ) ) ,
245
245
} ;
246
246
return match def {
247
- Some ( def) => SearchScope :: file_range ( def. as_ref ( ) . original_file_range ( db) ) ,
247
+ Some ( def) => SearchScope :: file_range ( def. as_ref ( ) . original_file_range_full ( db) ) ,
248
248
None => SearchScope :: single_file ( file_id) ,
249
249
} ;
250
250
}
251
251
252
252
if let Definition :: SelfType ( impl_) = self {
253
253
return match impl_. source ( db) . map ( |src| src. syntax ( ) . cloned ( ) ) {
254
- Some ( def) => SearchScope :: file_range ( def. as_ref ( ) . original_file_range ( db) ) ,
254
+ Some ( def) => SearchScope :: file_range ( def. as_ref ( ) . original_file_range_full ( db) ) ,
255
255
None => SearchScope :: single_file ( file_id) ,
256
256
} ;
257
257
}
@@ -268,7 +268,7 @@ impl Definition {
268
268
hir:: GenericDef :: Const ( it) => it. source ( db) . map ( |src| src. syntax ( ) . cloned ( ) ) ,
269
269
} ;
270
270
return match def {
271
- Some ( def) => SearchScope :: file_range ( def. as_ref ( ) . original_file_range ( db) ) ,
271
+ Some ( def) => SearchScope :: file_range ( def. as_ref ( ) . original_file_range_full ( db) ) ,
272
272
None => SearchScope :: single_file ( file_id) ,
273
273
} ;
274
274
}
@@ -319,10 +319,6 @@ impl Definition {
319
319
sema,
320
320
scope : None ,
321
321
include_self_kw_refs : None ,
322
- local_repr : match self {
323
- Definition :: Local ( local) => Some ( local) ,
324
- _ => None ,
325
- } ,
326
322
search_self_mod : false ,
327
323
}
328
324
}
@@ -337,9 +333,6 @@ pub struct FindUsages<'a> {
337
333
assoc_item_container : Option < hir:: AssocItemContainer > ,
338
334
/// whether to search for the `Self` type of the definition
339
335
include_self_kw_refs : Option < hir:: Type > ,
340
- /// the local representative for the local definition we are searching for
341
- /// (this is required for finding all local declarations in a or-pattern)
342
- local_repr : Option < hir:: Local > ,
343
336
/// whether to search for the `self` module
344
337
search_self_mod : bool ,
345
338
}
@@ -644,19 +637,6 @@ impl<'a> FindUsages<'a> {
644
637
sink : & mut dyn FnMut ( FileId , FileReference ) -> bool ,
645
638
) -> bool {
646
639
match NameRefClass :: classify ( self . sema , name_ref) {
647
- Some ( NameRefClass :: Definition ( def @ Definition :: Local ( local) ) )
648
- if matches ! (
649
- self . local_repr, Some ( repr) if repr == local
650
- ) =>
651
- {
652
- let FileRange { file_id, range } = self . sema . original_range ( name_ref. syntax ( ) ) ;
653
- let reference = FileReference {
654
- range,
655
- name : ast:: NameLike :: NameRef ( name_ref. clone ( ) ) ,
656
- category : ReferenceCategory :: new ( & def, name_ref) ,
657
- } ;
658
- sink ( file_id, reference)
659
- }
660
640
Some ( NameRefClass :: Definition ( def) )
661
641
if self . def == def
662
642
// is our def a trait assoc item? then we want to find all assoc items from trait impls of our trait
@@ -701,14 +681,16 @@ impl<'a> FindUsages<'a> {
701
681
}
702
682
}
703
683
Some ( NameRefClass :: FieldShorthand { local_ref : local, field_ref : field } ) => {
704
- let field = Definition :: Field ( field) ;
705
684
let FileRange { file_id, range } = self . sema . original_range ( name_ref. syntax ( ) ) ;
685
+
686
+ let field = Definition :: Field ( field) ;
687
+ let local = Definition :: Local ( local) ;
706
688
let access = match self . def {
707
689
Definition :: Field ( _) if field == self . def => {
708
690
ReferenceCategory :: new ( & field, name_ref)
709
691
}
710
- Definition :: Local ( _) if matches ! ( self . local_repr , Some ( repr ) if repr == local ) => {
711
- ReferenceCategory :: new ( & Definition :: Local ( local) , name_ref)
692
+ Definition :: Local ( _) if local == self . def => {
693
+ ReferenceCategory :: new ( & local, name_ref)
712
694
}
713
695
_ => return false ,
714
696
} ;
@@ -752,21 +734,6 @@ impl<'a> FindUsages<'a> {
752
734
} ;
753
735
sink ( file_id, reference)
754
736
}
755
- Some ( NameClass :: Definition ( def @ Definition :: Local ( local) ) ) if def != self . def => {
756
- if matches ! (
757
- self . local_repr,
758
- Some ( repr) if local == repr
759
- ) {
760
- let FileRange { file_id, range } = self . sema . original_range ( name. syntax ( ) ) ;
761
- let reference = FileReference {
762
- range,
763
- name : ast:: NameLike :: Name ( name. clone ( ) ) ,
764
- category : None ,
765
- } ;
766
- return sink ( file_id, reference) ;
767
- }
768
- false
769
- }
770
737
Some ( NameClass :: Definition ( def) ) if def != self . def => {
771
738
match ( & self . assoc_item_container , self . def ) {
772
739
// for type aliases we always want to reference the trait def and all the trait impl counterparts
0 commit comments