@@ -460,7 +460,8 @@ impl<'a> FindUsages<'a> {
460
460
// `name` is stripped of raw ident prefix. See the comment on name retrieval above.
461
461
it. text ( ) . trim_start_matches ( "r#" ) == name
462
462
} )
463
- . map ( |token| {
463
+ . into_iter ( )
464
+ . flat_map ( |token| {
464
465
// FIXME: There should be optimization potential here
465
466
// Currently we try to descend everything we find which
466
467
// means we call `Semantics::descend_into_macros` on
@@ -476,30 +477,23 @@ impl<'a> FindUsages<'a> {
476
477
477
478
// Search for occurrences of the items name
478
479
for offset in match_indices ( & text, finder, search_range) {
479
- if let Some ( iter) = find_nodes ( name, & tree, offset) {
480
- for name in iter. filter_map ( ast:: NameLike :: cast) {
481
- if match name {
482
- ast:: NameLike :: NameRef ( name_ref) => {
483
- self . found_name_ref ( & name_ref, sink)
484
- }
485
- ast:: NameLike :: Name ( name) => self . found_name ( & name, sink) ,
486
- ast:: NameLike :: Lifetime ( lifetime) => {
487
- self . found_lifetime ( & lifetime, sink)
488
- }
489
- } {
490
- return ;
491
- }
480
+ for name in find_nodes ( name, & tree, offset) . filter_map ( ast:: NameLike :: cast) {
481
+ if match name {
482
+ ast:: NameLike :: NameRef ( name_ref) => self . found_name_ref ( & name_ref, sink) ,
483
+ ast:: NameLike :: Name ( name) => self . found_name ( & name, sink) ,
484
+ ast:: NameLike :: Lifetime ( lifetime) => self . found_lifetime ( & lifetime, sink) ,
485
+ } {
486
+ return ;
492
487
}
493
488
}
494
489
}
495
490
// Search for occurrences of the `Self` referring to our type
496
491
if let Some ( ( self_ty, finder) ) = & include_self_kw_refs {
497
492
for offset in match_indices ( & text, finder, search_range) {
498
- if let Some ( iter) = find_nodes ( "Self" , & tree, offset) {
499
- for name_ref in iter. filter_map ( ast:: NameRef :: cast) {
500
- if self . found_self_ty_name_ref ( self_ty, & name_ref, sink) {
501
- return ;
502
- }
493
+ for name_ref in find_nodes ( "Self" , & tree, offset) . filter_map ( ast:: NameRef :: cast)
494
+ {
495
+ if self . found_self_ty_name_ref ( self_ty, & name_ref, sink) {
496
+ return ;
503
497
}
504
498
}
505
499
}
@@ -518,21 +512,21 @@ impl<'a> FindUsages<'a> {
518
512
let tree = Lazy :: new ( move || sema. parse ( file_id) . syntax ( ) . clone ( ) ) ;
519
513
520
514
for offset in match_indices ( & text, finder, search_range) {
521
- if let Some ( iter ) = find_nodes ( "super" , & tree , offset ) {
522
- for name_ref in iter . filter_map ( ast:: NameRef :: cast) {
523
- if self . found_name_ref ( & name_ref , sink ) {
524
- return ;
525
- }
515
+ for name_ref in
516
+ find_nodes ( "super" , & tree , offset ) . filter_map ( ast:: NameRef :: cast)
517
+ {
518
+ if self . found_name_ref ( & name_ref , sink ) {
519
+ return ;
526
520
}
527
521
}
528
522
}
529
523
if let Some ( finder) = & is_crate_root {
530
524
for offset in match_indices ( & text, finder, search_range) {
531
- if let Some ( iter ) = find_nodes ( "crate" , & tree , offset ) {
532
- for name_ref in iter . filter_map ( ast:: NameRef :: cast) {
533
- if self . found_name_ref ( & name_ref , sink ) {
534
- return ;
535
- }
525
+ for name_ref in
526
+ find_nodes ( "crate" , & tree , offset ) . filter_map ( ast:: NameRef :: cast)
527
+ {
528
+ if self . found_name_ref ( & name_ref , sink ) {
529
+ return ;
536
530
}
537
531
}
538
532
}
@@ -571,11 +565,10 @@ impl<'a> FindUsages<'a> {
571
565
let finder = & Finder :: new ( "self" ) ;
572
566
573
567
for offset in match_indices ( & text, finder, search_range) {
574
- if let Some ( iter) = find_nodes ( "self" , & tree, offset) {
575
- for name_ref in iter. filter_map ( ast:: NameRef :: cast) {
576
- if self . found_self_module_name_ref ( & name_ref, sink) {
577
- return ;
578
- }
568
+ for name_ref in find_nodes ( "self" , & tree, offset) . filter_map ( ast:: NameRef :: cast)
569
+ {
570
+ if self . found_self_module_name_ref ( & name_ref, sink) {
571
+ return ;
579
572
}
580
573
}
581
574
}
0 commit comments