File tree Expand file tree Collapse file tree 1 file changed +7
-15
lines changed Expand file tree Collapse file tree 1 file changed +7
-15
lines changed Original file line number Diff line number Diff line change @@ -16,24 +16,16 @@ pub(crate) fn goto_type_definition(
1616 let token = pick_best ( file. token_at_offset ( position. offset ) ) ?;
1717 let token = descend_into_macros ( db, position. file_id , token) ;
1818
19- let node = token. value . ancestors ( ) . find_map ( |token| {
20- token
21- . ancestors ( )
22- . find ( |n| ast:: Expr :: cast ( n. clone ( ) ) . is_some ( ) || ast:: Pat :: cast ( n. clone ( ) ) . is_some ( ) )
23- } ) ?;
19+ let node = token
20+ . value
21+ . ancestors ( )
22+ . find ( |n| ast:: Expr :: cast ( n. clone ( ) ) . is_some ( ) || ast:: Pat :: cast ( n. clone ( ) ) . is_some ( ) ) ?;
2423
2524 let analyzer = hir:: SourceAnalyzer :: new ( db, token. with_value ( & node) , None ) ;
2625
27- let ty: hir:: Type = if let Some ( ty) =
28- ast:: Expr :: cast ( node. clone ( ) ) . and_then ( |e| analyzer. type_of ( db, & e) )
29- {
30- ty
31- } else if let Some ( ty) = ast:: Pat :: cast ( node. clone ( ) ) . and_then ( |p| analyzer. type_of_pat ( db, & p) )
32- {
33- ty
34- } else {
35- return None ;
36- } ;
26+ let ty: hir:: Type = ast:: Expr :: cast ( node. clone ( ) )
27+ . and_then ( |e| analyzer. type_of ( db, & e) )
28+ . or_else ( || ast:: Pat :: cast ( node. clone ( ) ) . and_then ( |p| analyzer. type_of_pat ( db, & p) ) ) ?;
3729
3830 let adt_def = ty. autoderef ( db) . find_map ( |ty| ty. as_adt ( ) ) ?;
3931
You can’t perform that action at this time.
0 commit comments