summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r--src/codegen/mod.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 67d6b6d5..c1d6d53a 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -2585,9 +2585,17 @@ impl CodeGenerator for Enum {
}
if !variation.is_const() {
- attrs.push(attributes::derives(
- &["Debug", "Copy", "Clone", "PartialEq", "Eq", "Hash"],
- ));
+ let mut derives = vec!["Debug", "Copy", "Clone", "PartialEq", "Eq", "Hash"];
+
+ if item.can_derive_partialord(ctx) {
+ derives.push("PartialOrd");
+ }
+
+ if item.can_derive_ord(ctx) {
+ derives.push("Ord");
+ }
+
+ attrs.push(attributes::derives(&derives));
}
fn add_constant<'a>(