diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-09-24 04:55:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-24 04:55:54 -0400 |
commit | 65f6779fd8bd677a9ab8077f0006787ed2094408 (patch) | |
tree | 6dc12525a5fcc8a8ab4f0a8e49e809a090d3782c /src/codegen/mod.rs | |
parent | dcb9921446ddd38cdd2bc5d02911b65ca3dcf93b (diff) | |
parent | f9b2007ecd830adec8d98a25bcc2f84c104076ac (diff) |
Auto merge of #1396 - tathanhdinh:master, r=emilio
PartialOrd and Ord for enum
Hello all,
This PR tries to fix #1395.
Many thanks for any comment.
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r-- | src/codegen/mod.rs | 14 |
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>( |