@@ -420,29 +420,22 @@ fn assoc_fn_target_info(
420420) -> Option < TargetInfo > {
421421 let mut target_module = None ;
422422 let mut adt_name = None ;
423- let ( target, file, insert_offset) =
424- assoc_fn_target ( ctx, call, adt, & mut target_module, fn_name, & mut adt_name) ?;
423+ let ( target, file, insert_offset) = {
424+ let target_module: & mut Option < Module > = & mut target_module;
425+ let adt_name: & mut Option < hir:: Name > = & mut adt_name;
426+ let current_module = ctx. sema . scope ( call. syntax ( ) ) ?. module ( ) ;
427+ let module = adt. module ( ctx. sema . db ) ;
428+ * target_module = if current_module == module { None } else { Some ( module) } ;
429+ if current_module. krate ( ) != module. krate ( ) {
430+ return None ;
431+ }
432+ let ( impl_, file) = get_adt_source ( ctx, & adt, fn_name) ?;
433+ let ( target, insert_offset) = get_method_target ( ctx, & module, & impl_) ?;
434+ * adt_name = if impl_. is_none ( ) { Some ( adt. name ( ctx. sema . db ) ) } else { None } ;
435+ Some ( ( target, file, insert_offset) )
436+ } ?;
425437 Some ( TargetInfo { target_module, adt_name, target, file, insert_offset } )
426438}
427- fn assoc_fn_target (
428- ctx : & AssistContext < ' _ > ,
429- call : & CallExpr ,
430- adt : hir:: Adt ,
431- target_module : & mut Option < Module > ,
432- fn_name : & str ,
433- adt_name : & mut Option < hir:: Name > ,
434- ) -> Option < ( GeneratedFunctionTarget , FileId , TextSize ) > {
435- let current_module = ctx. sema . scope ( call. syntax ( ) ) ?. module ( ) ;
436- let module = adt. module ( ctx. sema . db ) ;
437- * target_module = if current_module == module { None } else { Some ( module) } ;
438- if current_module. krate ( ) != module. krate ( ) {
439- return None ;
440- }
441- let ( impl_, file) = get_adt_source ( ctx, & adt, fn_name) ?;
442- let ( target, insert_offset) = get_method_target ( ctx, & module, & impl_) ?;
443- * adt_name = if impl_. is_none ( ) { Some ( adt. name ( ctx. sema . db ) ) } else { None } ;
444- Some ( ( target, file, insert_offset) )
445- }
446439
447440fn get_insert_offset ( target : & GeneratedFunctionTarget ) -> TextSize {
448441 match & target {
0 commit comments