@@ -104,13 +104,10 @@ fn fn_target_info(
104
104
call : & CallExpr ,
105
105
fn_name : & str ,
106
106
) -> Option < TargetInfo > {
107
- let target_module;
108
- let adt_name = None ;
109
- let ( target, file, insert_offset) = match path. qualifier ( ) {
107
+ match path. qualifier ( ) {
110
108
Some ( qualifier) => match ctx. sema . resolve_path ( & qualifier) {
111
109
Some ( hir:: PathResolution :: Def ( hir:: ModuleDef :: Module ( module) ) ) => {
112
- target_module = Some ( module) ;
113
- get_fn_target ( ctx, & target_module, call. clone ( ) ) ?
110
+ get_fn_target_info ( ctx, & Some ( module) , call. clone ( ) )
114
111
}
115
112
Some ( hir:: PathResolution :: Def ( hir:: ModuleDef :: Adt ( adt) ) ) => {
116
113
if let hir:: Adt :: Enum ( _) = adt {
@@ -120,22 +117,16 @@ fn fn_target_info(
120
117
}
121
118
}
122
119
123
- return assoc_fn_target_info ( ctx, call, adt, fn_name) ;
120
+ assoc_fn_target_info ( ctx, call, adt, fn_name)
124
121
}
125
122
Some ( hir:: PathResolution :: SelfType ( impl_) ) => {
126
123
let adt = impl_. self_ty ( ctx. db ( ) ) . as_adt ( ) ?;
127
- return assoc_fn_target_info ( ctx, call, adt, fn_name) ;
128
- }
129
- _ => {
130
- return None ;
124
+ assoc_fn_target_info ( ctx, call, adt, fn_name)
131
125
}
126
+ _ => None ,
132
127
} ,
133
- _ => {
134
- target_module = None ;
135
- get_fn_target ( ctx, & target_module, call. clone ( ) ) ?
136
- }
137
- } ;
138
- Some ( TargetInfo :: new ( target_module, adt_name, target, file, insert_offset) )
128
+ _ => get_fn_target_info ( ctx, & None , call. clone ( ) ) ,
129
+ }
139
130
}
140
131
141
132
fn gen_method ( acc : & mut Assists , ctx : & AssistContext < ' _ > ) -> Option < ( ) > {
@@ -391,6 +382,15 @@ fn make_return_type(
391
382
( ret_type, should_focus_return_type)
392
383
}
393
384
385
+ fn get_fn_target_info (
386
+ ctx : & AssistContext < ' _ > ,
387
+ target_module : & Option < Module > ,
388
+ call : CallExpr ,
389
+ ) -> Option < TargetInfo > {
390
+ let ( target, file, insert_offset) = get_fn_target ( ctx, target_module, call) ?;
391
+ Some ( TargetInfo :: new ( * target_module, None , target, file, insert_offset) )
392
+ }
393
+
394
394
fn get_fn_target (
395
395
ctx : & AssistContext < ' _ > ,
396
396
target_module : & Option < Module > ,
0 commit comments