From a92ed1eef4a5804c474221d1088dafb5d45f1378 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 16 Jun 2021 19:27:06 +0200 Subject: Don't complete already used derive attributes --- .../src/completions/attribute/derive.rs | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'crates/ide_completion') diff --git a/crates/ide_completion/src/completions/attribute/derive.rs b/crates/ide_completion/src/completions/attribute/derive.rs index c59add6c5..20bbbba46 100644 --- a/crates/ide_completion/src/completions/attribute/derive.rs +++ b/crates/ide_completion/src/completions/attribute/derive.rs @@ -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 @@ pub macro Ord {} 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 @@ pub macro Ord {} 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 + "#]], ) } } -- cgit v1.2.3