Don't complete already used derive attributes

This commit is contained in:
Lukas Wirth 2021-06-16 19:27:06 +02:00
parent 8f936c5571
commit a92ed1eef4

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