@@ -244,14 +244,14 @@ impl Definition {
244244 DefWithBody :: Variant ( v) => v. source ( db) . map ( |src| src. syntax ( ) . cloned ( ) ) ,
245245 } ;
246246 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) ) ,
248248 None => SearchScope :: single_file ( file_id) ,
249249 } ;
250250 }
251251
252252 if let Definition :: SelfType ( impl_) = self {
253253 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) ) ,
255255 None => SearchScope :: single_file ( file_id) ,
256256 } ;
257257 }
@@ -268,7 +268,7 @@ impl Definition {
268268 hir:: GenericDef :: Const ( it) => it. source ( db) . map ( |src| src. syntax ( ) . cloned ( ) ) ,
269269 } ;
270270 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) ) ,
272272 None => SearchScope :: single_file ( file_id) ,
273273 } ;
274274 }
@@ -319,10 +319,6 @@ impl Definition {
319319 sema,
320320 scope : None ,
321321 include_self_kw_refs : None ,
322- local_repr : match self {
323- Definition :: Local ( local) => Some ( local) ,
324- _ => None ,
325- } ,
326322 search_self_mod : false ,
327323 }
328324 }
@@ -337,9 +333,6 @@ pub struct FindUsages<'a> {
337333 assoc_item_container : Option < hir:: AssocItemContainer > ,
338334 /// whether to search for the `Self` type of the definition
339335 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 > ,
343336 /// whether to search for the `self` module
344337 search_self_mod : bool ,
345338}
@@ -644,19 +637,6 @@ impl<'a> FindUsages<'a> {
644637 sink : & mut dyn FnMut ( FileId , FileReference ) -> bool ,
645638 ) -> bool {
646639 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- }
660640 Some ( NameRefClass :: Definition ( def) )
661641 if self . def == def
662642 // 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> {
701681 }
702682 }
703683 Some ( NameRefClass :: FieldShorthand { local_ref : local, field_ref : field } ) => {
704- let field = Definition :: Field ( field) ;
705684 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) ;
706688 let access = match self . def {
707689 Definition :: Field ( _) if field == self . def => {
708690 ReferenceCategory :: new ( & field, name_ref)
709691 }
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)
712694 }
713695 _ => return false ,
714696 } ;
@@ -752,21 +734,6 @@ impl<'a> FindUsages<'a> {
752734 } ;
753735 sink ( file_id, reference)
754736 }
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- }
770737 Some ( NameClass :: Definition ( def) ) if def != self . def => {
771738 match ( & self . assoc_item_container , self . def ) {
772739 // for type aliases we always want to reference the trait def and all the trait impl counterparts
0 commit comments