From a444c4f09ee15ea87d37e073ab7e0942a696cb41 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Jan 2015 15:03:58 -0800 Subject: [PATCH] std: Remove assert_receiver_is_total_eq I think that deriving must have made progress since it was originally written, this was a pretty easy change! Closes #13101 --- src/libcore/cmp.rs | 11 ++----- src/libcore/option.rs | 2 +- src/libcore/str/mod.rs | 2 +- src/libsyntax/ext/deriving/cmp/totaleq.rs | 37 ++--------------------- 4 files changed, 6 insertions(+), 46 deletions(-) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 367c794e84bb6..75b054cbb04ba 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -91,15 +91,8 @@ pub trait PartialEq for Sized? { /// - transitive: `a == b` and `b == c` implies `a == c`. #[stable] pub trait Eq for Sized?: PartialEq { - // FIXME #13101: this method is used solely by #[deriving] to - // assert that every component of a type implements #[deriving] - // itself, the current deriving infrastructure means doing this - // assertion without using a method on this trait is nearly - // impossible. - // - // This should never be implemented by hand. - #[doc(hidden)] - #[inline(always)] + #[cfg(stage0)] + #[allow(missing_docs)] fn assert_receiver_is_total_eq(&self) {} } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index d831a57893bd7..43283dd087620 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -145,7 +145,7 @@ use self::Option::*; -use cmp::{Eq, Ord}; +use cmp::Ord; use default::Default; use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator}; use iter::{ExactSizeIterator}; diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index f4fe86a0d7ec0..c513bf0992926 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -18,7 +18,7 @@ use self::Searcher::{Naive, TwoWay, TwoWayLong}; -use cmp::{mod, Eq}; +use cmp; use default::Default; use iter::range; use iter::{DoubleEndedIteratorExt, ExactSizeIterator}; diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 2b986bea1221e..33e889f613787 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{MetaItem, Item, Expr}; +use ast::{MetaItem, Item}; use codemap::Span; use ext::base::ExtCtxt; -use ext::build::AstBuilder; use ext::deriving::generic::*; use ext::deriving::generic::ty::*; -use parse::token::InternedString; use ptr::P; pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, @@ -24,44 +22,13 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, push: F) where F: FnOnce(P), { - fn cs_total_eq_assert(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P { - cs_same_method(|cx, span, exprs| { - // create `a.(); b.(); c.(); ...` - // (where method is `assert_receiver_is_total_eq`) - let stmts = exprs.into_iter().map(|e| cx.stmt_expr(e)).collect(); - let block = cx.block(span, stmts, None); - cx.expr_block(block) - }, - |cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(Eq)?"), - cx, - span, - substr) - } - - let inline = cx.meta_word(span, InternedString::new("inline")); - let hidden = cx.meta_word(span, InternedString::new("hidden")); - let doc = cx.meta_list(span, InternedString::new("doc"), vec!(hidden)); - let attrs = vec!(cx.attribute(span, inline), - cx.attribute(span, doc)); let trait_def = TraitDef { span: span, attributes: Vec::new(), path: Path::new(vec!("std", "cmp", "Eq")), additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), - methods: vec!( - MethodDef { - name: "assert_receiver_is_total_eq", - generics: LifetimeBounds::empty(), - explicit_self: borrowed_explicit_self(), - args: vec!(), - ret_ty: nil_ty(), - attributes: attrs, - combine_substructure: combine_substructure(|a, b, c| { - cs_total_eq_assert(a, b, c) - }) - } - ) + methods: Vec::new(), }; trait_def.expand(cx, mitem, item, push) }