File tree Expand file tree Collapse file tree 2 files changed +31
-6
lines changed
crates/ide-completion/src Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -427,6 +427,31 @@ fn foo() {
427
427
..Default::default()
428
428
};
429
429
}
430
+ "# ,
431
+ ) ;
432
+ }
433
+
434
+ #[ test]
435
+ fn callable_field_struct_init ( ) {
436
+ check_edit (
437
+ "field" ,
438
+ r#"
439
+ struct S {
440
+ field: fn(),
441
+ }
442
+
443
+ fn main() {
444
+ S {fi$0
445
+ }
446
+ "# ,
447
+ r#"
448
+ struct S {
449
+ field: fn(),
450
+ }
451
+
452
+ fn main() {
453
+ S {field
454
+ }
430
455
"# ,
431
456
) ;
432
457
}
Original file line number Diff line number Diff line change @@ -169,14 +169,14 @@ pub(crate) fn render_field(
169
169
if let Some ( receiver) = ctx. completion . sema . original_ast_node ( receiver. clone ( ) ) {
170
170
builder. insert ( receiver. syntax ( ) . text_range ( ) . start ( ) , "(" . to_string ( ) ) ;
171
171
builder. insert ( ctx. source_range ( ) . end ( ) , ")" . to_string ( ) ) ;
172
- }
173
- }
174
172
175
- let is_parens_needed =
176
- !matches ! ( dot_access. kind, DotAccessKind :: Method { has_parens: true } ) ;
173
+ let is_parens_needed =
174
+ !matches ! ( dot_access. kind, DotAccessKind :: Method { has_parens: true } ) ;
177
175
178
- if is_parens_needed {
179
- builder. insert ( ctx. source_range ( ) . end ( ) , "()" . to_string ( ) ) ;
176
+ if is_parens_needed {
177
+ builder. insert ( ctx. source_range ( ) . end ( ) , "()" . to_string ( ) ) ;
178
+ }
179
+ }
180
180
}
181
181
}
182
182
You can’t perform that action at this time.
0 commit comments