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 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
"#]],
);
}

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);
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() {