Skip to content

Commit bb96ee6

Browse files
committed
syntax: Prepare for Total{Eq,Ord} => {Eq,Ord}
This commit adds the groundwork for the renaming of the Total{Eq,Ord} traits. After this commit hits a snapshot, the traits can be renamed.
1 parent 748bc3c commit bb96ee6

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

src/libcore/cmp.rs

Lines changed: 3 additions & 0 deletions
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 Eq = self::TotalEq;
41+
pub use Ord = self::TotalOrd;
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

src/libcore/iter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2083,7 +2083,8 @@ pub struct RangeStep<A> {
20832083

20842084
/// Return an iterator over the range [start, stop) by `step`. It handles overflow by stopping.
20852085
#[inline]
2086-
pub fn range_step<A: CheckedAdd + PartialOrd + Clone + Zero>(start: A, stop: A, step: A) -> RangeStep<A> {
2086+
pub fn range_step<A: CheckedAdd + PartialOrd +
2087+
Clone + Zero>(start: A, stop: A, step: A) -> RangeStep<A> {
20872088
let rev = step < Zero::zero();
20882089
RangeStep{state: start, stop: stop, step: step, rev: rev}
20892090
}

src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ fn check_missing_doc_item(cx: &Context, it: &ast::Item) {
16501650
desc);
16511651
}
16521652

1653-
#[deriving(Eq)]
1653+
#[deriving(PartialEq)]
16541654
enum MethodContext {
16551655
TraitDefaultImpl,
16561656
TraitImpl,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
2828
let block = cx.block(span, stmts, None);
2929
cx.expr_block(block)
3030
},
31-
|cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(TotalEq)?"),
31+
|cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(Eq)?"),
3232
cx,
3333
span,
3434
substr)
@@ -42,7 +42,7 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
4242
let trait_def = TraitDef {
4343
span: span,
4444
attributes: Vec::new(),
45-
path: Path::new(vec!("std", "cmp", "TotalEq")),
45+
path: Path::new(vec!("std", "cmp", "Eq")),
4646
additional_bounds: Vec::new(),
4747
generics: LifetimeBounds::empty(),
4848
methods: vec!(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
2828
let trait_def = TraitDef {
2929
span: span,
3030
attributes: Vec::new(),
31-
path: Path::new(vec!("std", "cmp", "TotalOrd")),
31+
path: Path::new(vec!("std", "cmp", "Ord")),
3232
additional_bounds: Vec::new(),
3333
generics: LifetimeBounds::empty(),
3434
methods: vec!(
@@ -117,7 +117,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
117117
let order = ordering_const(cx, span, self_var.cmp(&other_var));
118118
cx.expr_path(order)
119119
}
120-
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(TotalOrd)`")
120+
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`")
121121
}
122122
},
123123
cx, span, substr)

src/libsyntax/ext/deriving/mod.rs

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

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

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

0 commit comments

Comments
 (0)