@@ -460,7 +460,8 @@ impl<'a> FindUsages<'a> {
460460 // `name` is stripped of raw ident prefix. See the comment on name retrieval above.
461461 it. text ( ) . trim_start_matches ( "r#" ) == name
462462 } )
463- . map ( |token| {
463+ . into_iter ( )
464+ . flat_map ( |token| {
464465 // FIXME: There should be optimization potential here
465466 // Currently we try to descend everything we find which
466467 // means we call `Semantics::descend_into_macros` on
@@ -476,30 +477,23 @@ impl<'a> FindUsages<'a> {
476477
477478 // Search for occurrences of the items name
478479 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 ;
492487 }
493488 }
494489 }
495490 // Search for occurrences of the `Self` referring to our type
496491 if let Some ( ( self_ty, finder) ) = & include_self_kw_refs {
497492 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 ;
503497 }
504498 }
505499 }
@@ -518,21 +512,21 @@ impl<'a> FindUsages<'a> {
518512 let tree = Lazy :: new ( move || sema. parse ( file_id) . syntax ( ) . clone ( ) ) ;
519513
520514 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 ;
526520 }
527521 }
528522 }
529523 if let Some ( finder) = & is_crate_root {
530524 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 ;
536530 }
537531 }
538532 }
@@ -571,11 +565,10 @@ impl<'a> FindUsages<'a> {
571565 let finder = & Finder :: new ( "self" ) ;
572566
573567 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 ;
579572 }
580573 }
581574 }
0 commit comments