From 2ac03ef1d6536955fb53baf25b9777e2a5176837 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 17 Jun 2021 15:54:59 +0200 Subject: Don't complete keywords in attributes inside expressions --- crates/ide_completion/src/completions/attribute.rs | 3 +-- crates/ide_completion/src/completions/keyword.rs | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/ide_completion') diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs index f3b11e72d..ab24a6521 100644 --- a/crates/ide_completion/src/completions/attribute.rs +++ b/crates/ide_completion/src/completions/attribute.rs @@ -786,13 +786,13 @@ mod tests { at target_feature = "…" at test at track_caller - kw return "#]], ); } #[test] fn complete_attribute_on_expr() { + cov_mark::check!(no_keyword_completion_in_attr_of_expr); check( r#"fn main() { #[$0] foo() }"#, expect![[r#" @@ -802,7 +802,6 @@ mod tests { at deny(…) at forbid(…) at warn(…) - kw return "#]], ); } diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs index c99fdef05..07541c79c 100644 --- a/crates/ide_completion/src/completions/keyword.rs +++ b/crates/ide_completion/src/completions/keyword.rs @@ -48,6 +48,10 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte cov_mark::hit!(no_keyword_completion_in_record_lit); return; } + if ctx.attribute_under_caret.is_some() { + cov_mark::hit!(no_keyword_completion_in_attr_of_expr); + return; + } // Suggest .await syntax for types that implement Future trait if let Some(receiver) = ctx.dot_receiver() { -- cgit v1.2.3