This repository was archived by the owner on May 28, 2025. It is now read-only.
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() {
427427 ..Default::default()
428428 };
429429}
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+ }
430455"# ,
431456 ) ;
432457 }
Original file line number Diff line number Diff line change @@ -169,14 +169,14 @@ pub(crate) fn render_field(
169169 if let Some ( receiver) = ctx. completion . sema . original_ast_node ( receiver. clone ( ) ) {
170170 builder. insert ( receiver. syntax ( ) . text_range ( ) . start ( ) , "(" . to_string ( ) ) ;
171171 builder. insert ( ctx. source_range ( ) . end ( ) , ")" . to_string ( ) ) ;
172- }
173- }
174172
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 } ) ;
177175
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+ }
180180 }
181181 }
182182
You can’t perform that action at this time.
0 commit comments