]> git.lizzy.rs Git - rust.git/commitdiff
Don't complete already used derive attributes
authorLukas Wirth <lukastw97@gmail.com>
Wed, 16 Jun 2021 17:27:06 +0000 (19:27 +0200)
committerLukas Wirth <lukastw97@gmail.com>
Wed, 16 Jun 2021 17:27:06 +0000 (19:27 +0200)
crates/ide_completion/src/completions/attribute/derive.rs

index c59add6c544d318b9e7fb5ce28d3be028bbf664b..20bbbba4643f49dbaa8e03079003045ed48ff9ec 100644 (file)
@@ -31,6 +31,8 @@ pub(super) fn complete_derive(
                 let lookup = components.join(", ");
                 let label = components.iter().rev().join(", ");
                 (label, Some(lookup))
+            } else if existing_derives.contains(&derive) {
+                continue;
             } else {
                 (derive, None)
             };
@@ -139,16 +141,15 @@ fn derive_with_input() {
         check(
             r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#,
             expect![[r#"
-            at PartialEq
-            at Default
-            at Eq
-            at Eq, PartialOrd, Ord
-            at Clone, Copy
-            at Debug
-            at Clone
-            at Hash
-            at PartialOrd
-        "#]],
+                at Default
+                at Eq
+                at Eq, PartialOrd, Ord
+                at Clone, Copy
+                at Debug
+                at Clone
+                at Hash
+                at PartialOrd
+            "#]],
         )
     }
 
@@ -157,16 +158,15 @@ fn derive_with_input2() {
         check(
             r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#,
             expect![[r#"
-            at PartialEq
-            at Default
-            at Eq
-            at Eq, PartialOrd, Ord
-            at Clone, Copy
-            at Debug
-            at Clone
-            at Hash
-            at PartialOrd
-        "#]],
+                at Default
+                at Eq
+                at Eq, PartialOrd, Ord
+                at Clone, Copy
+                at Debug
+                at Clone
+                at Hash
+                at PartialOrd
+            "#]],
         )
     }
 }