Skip to content

Commit 7b6e124

Browse files
authored
Merge pull request #22009 from A4-Tacks/no-expr-in-qualified
fix: no complete term expressions on qualified path
2 parents bf15a87 + 563d935 commit 7b6e124

5 files changed

Lines changed: 10 additions & 14 deletions

File tree

crates/ide-completion/src/completions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ pub(super) fn complete_name_ref(
756756
match &path_ctx.kind {
757757
PathKind::Expr { expr_ctx } => {
758758
expr::complete_expr_path(acc, ctx, path_ctx, expr_ctx);
759-
expr::complete_expr(acc, ctx);
759+
expr::complete_expr(acc, ctx, path_ctx);
760760

761761
dot::complete_undotted_self(acc, ctx, path_ctx, expr_ctx);
762762
item_list::complete_item_list_in_expr(acc, ctx, path_ctx, expr_ctx);

crates/ide-completion/src/completions/expr.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,11 @@ pub(crate) fn complete_expr_path(
451451
}
452452
}
453453

454-
pub(crate) fn complete_expr(acc: &mut Completions, ctx: &CompletionContext<'_>) {
454+
pub(crate) fn complete_expr(
455+
acc: &mut Completions,
456+
ctx: &CompletionContext<'_>,
457+
PathCompletionCtx { qualified, .. }: &PathCompletionCtx<'_>,
458+
) {
455459
let _p = tracing::info_span!("complete_expr").entered();
456460

457461
if !ctx.config.enable_term_search {
@@ -462,6 +466,10 @@ pub(crate) fn complete_expr(acc: &mut Completions, ctx: &CompletionContext<'_>)
462466
return;
463467
}
464468

469+
if !matches!(qualified, Qualified::No) {
470+
return;
471+
}
472+
465473
if let Some(ty) = &ctx.expected_type {
466474
// Ignore unit types as they are not very interesting
467475
if ty.is_unit() || ty.is_unknown() {

crates/ide-completion/src/render.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,6 @@ fn bb()-> &'static aa {
22112211
}
22122212
"#,
22132213
expect![[r#"
2214-
ex bb() [type]
22152214
fn from_bytes(…) fn(&[u8]) -> &aa [type_could_unify]
22162215
"#]],
22172216
);

crates/ide-completion/src/tests/expression.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,6 @@ fn main() {
10301030
"#,
10311031
expect![[r#"
10321032
fn test() fn() -> Zulu
1033-
ex Zulu
1034-
ex Zulu::test()
10351033
"#]],
10361034
);
10371035
}

crates/ide-completion/src/tests/special.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,6 @@ fn bar() -> Bar {
896896
"#,
897897
expect![[r#"
898898
fn foo() (as Foo) fn() -> Self
899-
ex Bar
900-
ex Bar::foo()
901-
ex bar()
902899
"#]],
903900
);
904901
}
@@ -926,9 +923,6 @@ fn bar() -> Bar {
926923
expect![[r#"
927924
fn bar() fn()
928925
fn foo() (as Foo) fn() -> Self
929-
ex Bar
930-
ex Bar::foo()
931-
ex bar()
932926
"#]],
933927
);
934928
}
@@ -955,9 +949,6 @@ fn bar() -> Bar {
955949
"#,
956950
expect![[r#"
957951
fn foo() (as Foo) fn() -> Self
958-
ex Bar
959-
ex Bar::foo()
960-
ex bar()
961952
"#]],
962953
);
963954
}

0 commit comments

Comments
 (0)