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 1
1
use hir:: { db:: HirDatabase , ModPath } ;
2
2
use ra_syntax:: {
3
3
ast:: { self , AstNode } ,
4
- SyntaxKind :: { NAME_REF , USE_ITEM } ,
5
4
SyntaxNode ,
6
5
} ;
7
6
@@ -33,11 +32,11 @@ pub(crate) fn auto_import<F: ImportsLocator>(
33
32
) -> Option < Assist > {
34
33
let path_to_import: ast:: Path = ctx. find_node_at_offset ( ) ?;
35
34
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 ( ) {
37
36
return None ;
38
37
}
39
38
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 ( ) ;
41
40
42
41
let module = path_to_import_syntax. ancestors ( ) . find_map ( ast:: Module :: cast) ;
43
42
let position = match module. and_then ( |it| it. item_list ( ) ) {
@@ -54,7 +53,7 @@ pub(crate) fn auto_import<F: ImportsLocator>(
54
53
}
55
54
56
55
let proposed_imports = imports_locator
57
- . find_imports ( & name_to_import. to_string ( ) )
56
+ . find_imports ( & name_to_import)
58
57
. into_iter ( )
59
58
. filter_map ( |module_def| module_with_name_to_import. find_use_path ( ctx. db , module_def) )
60
59
. filter ( |use_path| !use_path. segments . is_empty ( ) )
Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ fn main() {
376
376
let mut start = 0;
377
377
(0..2).for_each(|increment| {
378
378
start += increment;
379
- })
379
+ });
380
380
381
381
let multiply = |a, b, c, d| a * b * c * d;
382
382
let _: i32 = multiply(1, 2, 3, 4);
@@ -399,37 +399,37 @@ fn main() {
399
399
label: "i32",
400
400
},
401
401
InlayHint {
402
- range: [114; 122 ),
402
+ range: [115; 123 ),
403
403
kind: TypeHint,
404
404
label: "|…| -> i32",
405
405
},
406
406
InlayHint {
407
- range: [126; 127 ),
407
+ range: [127; 128 ),
408
408
kind: TypeHint,
409
409
label: "i32",
410
410
},
411
411
InlayHint {
412
- range: [129; 130 ),
412
+ range: [130; 131 ),
413
413
kind: TypeHint,
414
414
label: "i32",
415
415
},
416
416
InlayHint {
417
- range: [132; 133 ),
417
+ range: [133; 134 ),
418
418
kind: TypeHint,
419
419
label: "i32",
420
420
},
421
421
InlayHint {
422
- range: [135; 136 ),
422
+ range: [136; 137 ),
423
423
kind: TypeHint,
424
424
label: "i32",
425
425
},
426
426
InlayHint {
427
- range: [200; 212 ),
427
+ range: [201; 213 ),
428
428
kind: TypeHint,
429
429
label: "&|…| -> i32",
430
430
},
431
431
InlayHint {
432
- range: [235; 244 ),
432
+ range: [236; 245 ),
433
433
kind: TypeHint,
434
434
label: "|| -> i32",
435
435
},
You can’t perform that action at this time.
0 commit comments