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.
This commit is contained in:
Alex Crichton 2014-05-29 20:57:18 -07:00
parent 748bc3ca49
commit bb96ee6123
6 changed files with 13 additions and 8 deletions

View File

@ -37,6 +37,9 @@
//! assert!(SketchyNum {num: 25} != SketchyNum {num: 57});
//! ```
pub use Eq = self::TotalEq;
pub use Ord = self::TotalOrd;
/// Trait for values that can be compared for equality and inequality.
///
/// This trait allows partial equality, where types can be unordered instead of

View File

@ -2083,7 +2083,8 @@ pub struct RangeStep<A> {
/// Return an iterator over the range [start, stop) by `step`. It handles overflow by stopping.
#[inline]
pub fn range_step<A: CheckedAdd + PartialOrd + Clone + Zero>(start: A, stop: A, step: A) -> RangeStep<A> {
pub fn range_step<A: CheckedAdd + PartialOrd +
Clone + Zero>(start: A, stop: A, step: A) -> RangeStep<A> {
let rev = step < Zero::zero();
RangeStep{state: start, stop: stop, step: step, rev: rev}
}

View File

@ -1650,7 +1650,7 @@ fn check_missing_doc_item(cx: &Context, it: &ast::Item) {
desc);
}
#[deriving(Eq)]
#[deriving(PartialEq)]
enum MethodContext {
TraitDefaultImpl,
TraitImpl,

View File

@ -28,7 +28,7 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
let block = cx.block(span, stmts, None);
cx.expr_block(block)
},
|cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(TotalEq)?"),
|cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(Eq)?"),
cx,
span,
substr)
@ -42,7 +42,7 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
path: Path::new(vec!("std", "cmp", "TotalEq")),
path: Path::new(vec!("std", "cmp", "Eq")),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!(

View File

@ -28,7 +28,7 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt,
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
path: Path::new(vec!("std", "cmp", "TotalOrd")),
path: Path::new(vec!("std", "cmp", "Ord")),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!(
@ -117,7 +117,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
let order = ordering_const(cx, span, self_var.cmp(&other_var));
cx.expr_path(order)
}
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(TotalOrd)`")
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`")
}
},
cx, span, substr)

View File

@ -77,10 +77,11 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
"Encodable" => expand!(encodable::expand_deriving_encodable),
"Decodable" => expand!(decodable::expand_deriving_decodable),
// NOTE: after a stage0 snap this needs treatment
"PartialEq" => expand!(eq::expand_deriving_eq),
"TotalEq" => expand!(totaleq::expand_deriving_totaleq),
"Eq" | "TotalEq" => expand!(totaleq::expand_deriving_totaleq),
"PartialOrd" => expand!(ord::expand_deriving_ord),
"TotalOrd" => expand!(totalord::expand_deriving_totalord),
"Ord" | "TotalOrd" => expand!(totalord::expand_deriving_totalord),
"Rand" => expand!(rand::expand_deriving_rand),