Skip to content

Commit

Permalink
Auto merge of rust-lang#12596 - Veykril:completions, r=Veykril
Browse files Browse the repository at this point in the history
fix: Don't trigger pattern completions when typing a wildcard pattern

Fixes rust-lang/rust-analyzer#12592
  • Loading branch information
bors committed Jun 20, 2022
2 parents a1ff3ca + 1f02840 commit 9fdfa9f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/ide-completion/src/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,11 @@ pub(super) fn complete_name(
NameKind::Function => {
item_list::trait_impl::complete_trait_impl_fn(acc, ctx, name);
}
NameKind::IdentPat(pattern_ctx) => complete_patterns(acc, ctx, pattern_ctx),
NameKind::IdentPat(pattern_ctx) => {
if ctx.token.kind() != syntax::T![_] {
complete_patterns(acc, ctx, pattern_ctx)
}
}
NameKind::Module(mod_under_caret) => {
mod_::complete_mod(acc, ctx, mod_under_caret);
}
Expand Down
12 changes: 12 additions & 0 deletions crates/ide-completion/src/tests/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ fn check(ra_fixture: &str, expect: Expect) {
expect.assert_eq(&actual)
}

#[test]
fn wildcard() {
check(
r#"
fn quux() {
let _$0
}
"#,
expect![""],
);
}

#[test]
fn ident_rebind_pat() {
check_empty(
Expand Down

0 comments on commit 9fdfa9f

Please sign in to comment.