Skip to content

Commit f786f9b

Browse files
committed
rustc: Accept PartialOrd/PartialOrdEq for Eq/Ord
This is a transitionary step towards completing #12517. This change modifies the compiler to accept Partial{Ord,Eq} as deriving modes which will currently expand to implementations of PartialOrd and PartialEq (synonyms for Eq/Ord). After a snapshot, all of deriving(Eq, Ord) will be removed, and after a snapshot of that, TotalEq/TotalOrd will be renamed to Eq/Ord.
1 parent 24b1ce1 commit f786f9b

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

Diff for: src/libcore/cmp.rs

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
//! assert!(SketchyNum {num: 25} != SketchyNum {num: 57});
3838
//! ```
3939
40+
pub use PartialEq = cmp::Eq;
41+
pub use PartialOrd = cmp::Ord;
42+
4043
/// Trait for values that can be compared for equality and inequality.
4144
///
4245
/// This trait allows partial equality, where types can be unordered instead of

Diff for: src/libsyntax/ext/deriving/cmp/eq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
5353
let trait_def = TraitDef {
5454
span: span,
5555
attributes: Vec::new(),
56-
path: Path::new(vec!("std", "cmp", "Eq")),
56+
path: Path::new(vec!("std", "cmp", "PartialEq")),
5757
additional_bounds: Vec::new(),
5858
generics: LifetimeBounds::empty(),
5959
methods: vec!(

Diff for: src/libsyntax/ext/deriving/cmp/ord.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
4343
let trait_def = TraitDef {
4444
span: span,
4545
attributes: Vec::new(),
46-
path: Path::new(vec!("std", "cmp", "Ord")),
46+
path: Path::new(vec!("std", "cmp", "PartialOrd")),
4747
additional_bounds: Vec::new(),
4848
generics: LifetimeBounds::empty(),
4949
methods: vec!(

Diff for: src/libsyntax/ext/deriving/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
7777
"Encodable" => expand!(encodable::expand_deriving_encodable),
7878
"Decodable" => expand!(decodable::expand_deriving_decodable),
7979

80-
"Eq" => expand!(eq::expand_deriving_eq),
80+
// NOTE this needs treatment after a stage0 snap
81+
"PartialEq" | "Eq" => expand!(eq::expand_deriving_eq),
8182
"TotalEq" => expand!(totaleq::expand_deriving_totaleq),
82-
"Ord" => expand!(ord::expand_deriving_ord),
83+
"PartialOrd" | "Ord" => expand!(ord::expand_deriving_ord),
8384
"TotalOrd" => expand!(totalord::expand_deriving_totalord),
8485

8586
"Rand" => expand!(rand::expand_deriving_rand),

0 commit comments

Comments
 (0)