Skip to content

Commit 6dbb0ef

Browse files
committed
syntax: Make #[derive(Ord)] imply #[derive(PartialOrd)]
1 parent f5b939a commit 6dbb0ef

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/libsyntax/ext/deriving/cmp/ord.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use ext::deriving::generic::ty::*;
1818
use parse::token::InternedString;
1919
use ptr::P;
2020

21+
use super::partial_ord;
22+
2123
pub fn expand_deriving_ord(cx: &mut ExtCtxt,
2224
span: Span,
2325
mitem: &MetaItem,
@@ -48,7 +50,9 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
4850
associated_types: Vec::new(),
4951
};
5052

51-
trait_def.expand(cx, mitem, item, push)
53+
trait_def.expand(cx, mitem, item, push);
54+
55+
partial_ord::expand_deriving_partial_ord(cx, span, mitem, item, push)
5256
}
5357

5458

src/libsyntax/ext/deriving/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ fn expand_derive(cx: &mut ExtCtxt,
9595
// FIXME: This can be removed after a snapshot
9696
let mut seen_copy = false;
9797
let mut seen_eq = false;
98+
let mut seen_ord = false;
9899

99100
for titem in traits.iter() {
100101
match titem.node {
101102
MetaWord(ref tname) => {
102103
match &**tname {
103104
"Copy" => { seen_copy = true; }
104105
"Eq" => { seen_eq = true; }
106+
"Ord" => { seen_ord = true; }
105107
_ => { }
106108
}
107109
}
@@ -129,6 +131,7 @@ fn expand_derive(cx: &mut ExtCtxt,
129131
// FIXME: This can be removed after a snapshot
130132
if seen_copy && &**tname == "Clone" { continue; }
131133
if seen_eq && &**tname == "PartialEq" { continue; }
134+
if seen_ord && &**tname == "PartialOrd" { continue; }
132135

133136
// #[derive(Foo, Bar)] expands to #[derive_Foo] #[derive_Bar]
134137
item.attrs.push(cx.attribute(titem.span, cx.meta_word(titem.span,

0 commit comments

Comments
 (0)