@@ -36,13 +36,11 @@ pub(crate) fn goto_type_definition(
36
36
}
37
37
}
38
38
} ;
39
-
40
- // TODO this became pretty baroque after refactoring for `descend_into_macros(_many)`
41
- let range = sema
42
- . descend_into_macros ( token)
39
+ let range = token. text_range ( ) ;
40
+ sema. descend_into_macros ( token)
43
41
. iter ( )
44
42
. filter_map ( |token| {
45
- let ty_range = sema. token_ancestors_with_macros ( token. clone ( ) ) . find_map ( |node| {
43
+ let ty = sema. token_ancestors_with_macros ( token. clone ( ) ) . find_map ( |node| {
46
44
let ty = match_ast ! {
47
45
match node {
48
46
ast:: Expr ( it) => sema. type_of_expr( & it) ?. original,
@@ -64,12 +62,11 @@ pub(crate) fn goto_type_definition(
64
62
}
65
63
} ;
66
64
67
- let range = node. text_range ( ) ;
68
- Some ( ( ty, range. start ( ) , range. end ( ) ) )
65
+ Some ( ty)
69
66
} ) ;
70
- ty_range
67
+ ty
71
68
} )
72
- . inspect ( | ( ty , _range_start , _range_end ) | {
69
+ . for_each ( |ty | {
73
70
// collect from each `ty` into the `res` result vec
74
71
let ty = ty. strip_references ( ) ;
75
72
ty. walk ( db, |t| {
@@ -83,14 +80,12 @@ pub(crate) fn goto_type_definition(
83
80
push ( trait_. into ( ) ) ;
84
81
}
85
82
} ) ;
86
- } ) // reduce all ranges into a single umbrella span (TODO fishy?)
87
- . map ( |( _, range_start, range_end) | ( range_start, range_end) )
88
- . reduce ( |( start_acc, end_acc) , ( start_cur, end_cur) | {
89
- ( start_acc. min ( start_cur) , end_acc. max ( end_cur) )
90
- } )
91
- . map ( |( range_start, range_end) | TextRange :: new ( range_start, range_end) ) ?; // TODO easy to miss `?` bail
92
-
93
- Some ( RangeInfo :: new ( range, res) )
83
+ } ) ;
84
+ if res. is_empty ( ) {
85
+ None
86
+ } else {
87
+ Some ( RangeInfo :: new ( range, res) )
88
+ }
94
89
}
95
90
96
91
#[ cfg( test) ]
0 commit comments