Don't complete keywords in attributes inside expressions

This commit is contained in:
Lukas Wirth 2021-06-17 15:54:59 +02:00
parent 2a48b53220
commit 2ac03ef1d6
2 changed files with 5 additions and 2 deletions

View file

@ -786,13 +786,13 @@ mod tests {
at target_feature = "" at target_feature = ""
at test at test
at track_caller at track_caller
kw return
"#]], "#]],
); );
} }
#[test] #[test]
fn complete_attribute_on_expr() { fn complete_attribute_on_expr() {
cov_mark::check!(no_keyword_completion_in_attr_of_expr);
check( check(
r#"fn main() { #[$0] foo() }"#, r#"fn main() { #[$0] foo() }"#,
expect![[r#" expect![[r#"
@ -802,7 +802,6 @@ mod tests {
at deny() at deny()
at forbid() at forbid()
at warn() at warn()
kw return
"#]], "#]],
); );
} }

View file

@ -48,6 +48,10 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
cov_mark::hit!(no_keyword_completion_in_record_lit); cov_mark::hit!(no_keyword_completion_in_record_lit);
return; 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 // Suggest .await syntax for types that implement Future trait
if let Some(receiver) = ctx.dot_receiver() { if let Some(receiver) = ctx.dot_receiver() {