aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/attribute.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions/attribute.rs')
-rw-r--r--crates/ide_completion/src/completions/attribute.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs
index 6df569c2a..78fc30e16 100644
--- a/crates/ide_completion/src/completions/attribute.rs
+++ b/crates/ide_completion/src/completions/attribute.rs
@@ -17,12 +17,14 @@ use crate::{
17 17
18mod derive; 18mod derive;
19mod lint; 19mod lint;
20mod repr;
20 21
21pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 22pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
22 let attribute = ctx.attribute_under_caret.as_ref()?; 23 let attribute = ctx.attribute_under_caret.as_ref()?;
23 match (attribute.path().and_then(|p| p.as_single_name_ref()), attribute.token_tree()) { 24 match (attribute.path().and_then(|p| p.as_single_name_ref()), attribute.token_tree()) {
24 (Some(path), Some(token_tree)) => match path.text().as_str() { 25 (Some(path), Some(token_tree)) => match path.text().as_str() {
25 "derive" => derive::complete_derive(acc, ctx, token_tree), 26 "derive" => derive::complete_derive(acc, ctx, token_tree),
27 "repr" => repr::complete_repr(acc, ctx, token_tree),
26 "feature" => lint::complete_lint(acc, ctx, token_tree, FEATURES), 28 "feature" => lint::complete_lint(acc, ctx, token_tree, FEATURES),
27 "allow" | "warn" | "deny" | "forbid" => { 29 "allow" | "warn" | "deny" | "forbid" => {
28 lint::complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINTS); 30 lint::complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINTS);
@@ -322,7 +324,7 @@ mod tests {
322 324
323 use expect_test::{expect, Expect}; 325 use expect_test::{expect, Expect};
324 326
325 use crate::{test_utils::completion_list, CompletionKind}; 327 use crate::tests::completion_list;
326 328
327 #[test] 329 #[test]
328 fn attributes_are_sorted() { 330 fn attributes_are_sorted() {
@@ -341,7 +343,7 @@ mod tests {
341 } 343 }
342 344
343 fn check(ra_fixture: &str, expect: Expect) { 345 fn check(ra_fixture: &str, expect: Expect) {
344 let actual = completion_list(ra_fixture, CompletionKind::Attribute); 346 let actual = completion_list(ra_fixture);
345 expect.assert_eq(&actual); 347 expect.assert_eq(&actual);
346 } 348 }
347 349
@@ -792,6 +794,7 @@ mod tests {
792 794
793 #[test] 795 #[test]
794 fn complete_attribute_on_expr() { 796 fn complete_attribute_on_expr() {
797 cov_mark::check!(no_keyword_completion_in_attr_of_expr);
795 check( 798 check(
796 r#"fn main() { #[$0] foo() }"#, 799 r#"fn main() { #[$0] foo() }"#,
797 expect![[r#" 800 expect![[r#"