@@ -494,41 +494,37 @@ impl<'a> FindUsages<'a> {
494
494
}
495
495
496
496
// Search for `super` and `crate` resolving to our module
497
- match self . def {
498
- Definition :: Module ( module) => {
499
- let scope = search_scope
500
- . intersection ( & SearchScope :: module_and_children ( self . sema . db , module) ) ;
497
+ if let Definition :: Module ( module) = self . def {
498
+ let scope =
499
+ search_scope. intersection ( & SearchScope :: module_and_children ( self . sema . db , module) ) ;
501
500
502
- let is_crate_root =
503
- module. is_crate_root ( self . sema . db ) . then ( || Finder :: new ( "crate" ) ) ;
504
- let finder = & Finder :: new ( "super" ) ;
501
+ let is_crate_root = module. is_crate_root ( self . sema . db ) . then ( || Finder :: new ( "crate" ) ) ;
502
+ let finder = & Finder :: new ( "super" ) ;
505
503
506
- for ( text, file_id, search_range) in scope_files ( sema, & scope) {
507
- let tree = Lazy :: new ( move || sema. parse ( file_id) . syntax ( ) . clone ( ) ) ;
504
+ for ( text, file_id, search_range) in scope_files ( sema, & scope) {
505
+ let tree = Lazy :: new ( move || sema. parse ( file_id) . syntax ( ) . clone ( ) ) ;
508
506
507
+ for offset in match_indices ( & text, finder, search_range) {
508
+ if let Some ( iter) = find_nodes ( "super" , & tree, offset) {
509
+ for name_ref in iter. filter_map ( ast:: NameRef :: cast) {
510
+ if self . found_name_ref ( & name_ref, sink) {
511
+ return ;
512
+ }
513
+ }
514
+ }
515
+ }
516
+ if let Some ( finder) = & is_crate_root {
509
517
for offset in match_indices ( & text, finder, search_range) {
510
- if let Some ( iter) = find_nodes ( "super " , & tree, offset) {
518
+ if let Some ( iter) = find_nodes ( "crate " , & tree, offset) {
511
519
for name_ref in iter. filter_map ( ast:: NameRef :: cast) {
512
520
if self . found_name_ref ( & name_ref, sink) {
513
521
return ;
514
522
}
515
523
}
516
524
}
517
525
}
518
- if let Some ( finder) = & is_crate_root {
519
- for offset in match_indices ( & text, finder, search_range) {
520
- if let Some ( iter) = find_nodes ( "crate" , & tree, offset) {
521
- for name_ref in iter. filter_map ( ast:: NameRef :: cast) {
522
- if self . found_name_ref ( & name_ref, sink) {
523
- return ;
524
- }
525
- }
526
- }
527
- }
528
- }
529
526
}
530
527
}
531
- _ => ( ) ,
532
528
}
533
529
534
530
// search for module `self` references in our module's definition source
0 commit comments