File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 11use hir:: { db:: HirDatabase , ModPath } ;
22use ra_syntax:: {
33 ast:: { self , AstNode } ,
4- SyntaxKind :: { NAME_REF , USE_ITEM } ,
54 SyntaxNode ,
65} ;
76
@@ -33,11 +32,11 @@ pub(crate) fn auto_import<F: ImportsLocator>(
3332) -> Option < Assist > {
3433 let path_to_import: ast:: Path = ctx. find_node_at_offset ( ) ?;
3534 let path_to_import_syntax = path_to_import. syntax ( ) ;
36- if path_to_import_syntax. ancestors ( ) . find ( |ancestor| ancestor . kind ( ) == USE_ITEM ) . is_some ( ) {
35+ if path_to_import_syntax. ancestors ( ) . find_map ( ast :: UseItem :: cast ) . is_some ( ) {
3736 return None ;
3837 }
3938 let name_to_import =
40- path_to_import_syntax. descendants ( ) . find ( |child| child . kind ( ) == NAME_REF ) ? ;
39+ path_to_import_syntax. descendants ( ) . find_map ( ast :: NameRef :: cast ) ? . syntax ( ) . to_string ( ) ;
4140
4241 let module = path_to_import_syntax. ancestors ( ) . find_map ( ast:: Module :: cast) ;
4342 let position = match module. and_then ( |it| it. item_list ( ) ) {
@@ -54,7 +53,7 @@ pub(crate) fn auto_import<F: ImportsLocator>(
5453 }
5554
5655 let proposed_imports = imports_locator
57- . find_imports ( & name_to_import. to_string ( ) )
56+ . find_imports ( & name_to_import)
5857 . into_iter ( )
5958 . filter_map ( |module_def| module_with_name_to_import. find_use_path ( ctx. db , module_def) )
6059 . filter ( |use_path| !use_path. segments . is_empty ( ) )
Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ fn main() {
376376 let mut start = 0;
377377 (0..2).for_each(|increment| {
378378 start += increment;
379- })
379+ });
380380
381381 let multiply = |a, b, c, d| a * b * c * d;
382382 let _: i32 = multiply(1, 2, 3, 4);
@@ -399,37 +399,37 @@ fn main() {
399399 label: "i32",
400400 },
401401 InlayHint {
402- range: [114; 122 ),
402+ range: [115; 123 ),
403403 kind: TypeHint,
404404 label: "|…| -> i32",
405405 },
406406 InlayHint {
407- range: [126; 127 ),
407+ range: [127; 128 ),
408408 kind: TypeHint,
409409 label: "i32",
410410 },
411411 InlayHint {
412- range: [129; 130 ),
412+ range: [130; 131 ),
413413 kind: TypeHint,
414414 label: "i32",
415415 },
416416 InlayHint {
417- range: [132; 133 ),
417+ range: [133; 134 ),
418418 kind: TypeHint,
419419 label: "i32",
420420 },
421421 InlayHint {
422- range: [135; 136 ),
422+ range: [136; 137 ),
423423 kind: TypeHint,
424424 label: "i32",
425425 },
426426 InlayHint {
427- range: [200; 212 ),
427+ range: [201; 213 ),
428428 kind: TypeHint,
429429 label: "&|…| -> i32",
430430 },
431431 InlayHint {
432- range: [235; 244 ),
432+ range: [236; 245 ),
433433 kind: TypeHint,
434434 label: "|| -> i32",
435435 },
You can’t perform that action at this time.
0 commit comments