Skip to content

Commit 9a42783

Browse files
committed
fix: Disable ref_match for qualified paths as well
I.e. don't suggest `Foo::&foo()`. CC #8058.
1 parent 02dd316 commit 9a42783

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

crates/ide_completion/src/render.rs

+37
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,43 @@ fn foo(f: Foo) { let _: &u32 = f.b$0 }
14671467
);
14681468
}
14691469

1470+
#[test]
1471+
fn qualified_path_ref() {
1472+
// disabled right now because it doesn't render correctly, #8058
1473+
check_kinds(
1474+
r#"
1475+
struct S;
1476+
1477+
struct T;
1478+
impl T {
1479+
fn foo() -> S {}
1480+
}
1481+
1482+
fn bar(s: &S) {}
1483+
1484+
fn main() {
1485+
bar(T::$0);
1486+
}
1487+
"#,
1488+
&[CompletionItemKind::SymbolKind(SymbolKind::Function)],
1489+
expect![[r#"
1490+
[
1491+
CompletionItem {
1492+
label: "foo()",
1493+
source_range: 95..95,
1494+
delete: 95..95,
1495+
insert: "foo()$0",
1496+
kind: SymbolKind(
1497+
Function,
1498+
),
1499+
lookup: "foo",
1500+
detail: "fn() -> S",
1501+
},
1502+
]
1503+
"#]],
1504+
);
1505+
}
1506+
14701507
#[test]
14711508
fn generic_enum() {
14721509
check_relevance(

crates/ide_completion/src/render/function.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ fn render(
7474
});
7575

7676
if let Some(ref_match) = compute_ref_match(completion, &ret_type) {
77-
// FIXME
78-
// For now we don't properly calculate the edits for ref match
79-
// completions on methods, so we've disabled them. See #8058.
80-
if matches!(func_kind, FuncKind::Function) {
77+
// FIXME For now we don't properly calculate the edits for ref match
78+
// completions on methods or qualified paths, so we've disabled them.
79+
// See #8058.
80+
if matches!(func_kind, FuncKind::Function) && ctx.completion.path_qual().is_none() {
8181
item.ref_match(ref_match);
8282
}
8383
}

0 commit comments

Comments
 (0)