summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 1bff1e26..7e183ad5 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -2590,9 +2590,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>(