diff --git a/crates/ide-completion/src/completions/dot.rs b/crates/ide-completion/src/completions/dot.rs index 81acfc8ecf..57e0646109 100644 --- a/crates/ide-completion/src/completions/dot.rs +++ b/crates/ide-completion/src/completions/dot.rs @@ -37,9 +37,6 @@ pub(crate) fn complete_dot( is_field_access, ); - if let DotAccessKind::Method { .. } = dot_access.kind { - cov_mark::hit!(test_no_struct_field_completion_for_method_call); - } complete_methods(ctx, receiver_ty, |func| acc.add_method(ctx, dot_access, func, None, None)); } @@ -259,7 +256,6 @@ impl A { #[test] fn test_no_struct_field_completion_for_method_call() { - cov_mark::check!(test_no_struct_field_completion_for_method_call); check( r#" struct A { the_field: u32 } @@ -1202,7 +1198,7 @@ fn foo() { S { va_field: 0, fn_field: || {} }.fi$0() } "#, r#" struct S { va_field: u32, fn_field: fn() } -fn foo() { (S { va_field: 0, fn_field: || {} }).fn_field() } +fn foo() { (S { va_field: 0, fn_field: || {} }.fn_field)() } "#, ); } @@ -1235,7 +1231,7 @@ fn foo() { struct B(u32, fn()) fn foo() { let b = B(0, || {}); - (b).1() + (b.1)() } "#, ) diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs index 453ff061bc..048730c078 100644 --- a/crates/ide-completion/src/render.rs +++ b/crates/ide-completion/src/render.rs @@ -167,9 +167,8 @@ pub(crate) fn render_field( if !expected_fn_type { if let Some(receiver) = &dot_access.receiver { if let Some(receiver) = ctx.completion.sema.original_ast_node(receiver.clone()) { - let range = receiver.syntax().text_range(); - builder.insert(range.start(), "(".to_string()); - builder.insert(range.end(), ")".to_string()); + builder.insert(receiver.syntax().text_range().start(), "(".to_string()); + builder.insert(ctx.source_range().end(), ")".to_string()); } } @@ -1676,11 +1675,7 @@ fn foo(f: Foo) { let _: &u32 = f.b$0 } delete: 107..107, }, Indel { - insert: ")", - delete: 108..108, - }, - Indel { - insert: "qux()", + insert: "qux)()", delete: 109..110, }, ],