about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2016-02-08 13:16:12 +0100
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2016-02-11 12:34:48 +0100
commit05e25de4f0add7ae3cd0e8f66cd4558c5bfa42aa (patch)
tree587130bb0d9d974e579d5a92a4893412351069fe
parentf875f4c4c24e8a14c04bbe4eedd230c4aa3c1431 (diff)
downloadrust-05e25de4f0add7ae3cd0e8f66cd4558c5bfa42aa.tar.gz
rust-05e25de4f0add7ae3cd0e8f66cd4558c5bfa42aa.zip
[breaking-change] don't glob export ast::BinOp_
-rw-r--r--src/librustc_front/lowering.rs36
-rw-r--r--src/libsyntax/ast.rs93
-rw-r--r--src/libsyntax/ext/build.rs4
-rw-r--r--src/libsyntax/parse/parser.rs37
-rw-r--r--src/libsyntax/parse/token.rs40
-rw-r--r--src/libsyntax/util/parser.rs80
-rw-r--r--src/libsyntax_ext/deriving/cmp/ord.rs5
-rw-r--r--src/libsyntax_ext/deriving/cmp/partial_eq.rs10
-rw-r--r--src/libsyntax_ext/deriving/cmp/partial_ord.rs11
-rw-r--r--src/libsyntax_ext/deriving/generic/mod.rs8
-rw-r--r--src/test/auxiliary/custom_derive_plugin.rs2
-rw-r--r--src/test/auxiliary/custom_derive_plugin_attr.rs2
12 files changed, 164 insertions, 164 deletions
diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs
index 698d82adff4..662eaf136c2 100644
--- a/src/librustc_front/lowering.rs
+++ b/src/librustc_front/lowering.rs
@@ -885,24 +885,24 @@ pub fn lower_unop(_lctx: &LoweringContext, u: UnOp) -> hir::UnOp {
 pub fn lower_binop(_lctx: &LoweringContext, b: BinOp) -> hir::BinOp {
     Spanned {
         node: match b.node {
-            BiAdd => hir::BiAdd,
-            BiSub => hir::BiSub,
-            BiMul => hir::BiMul,
-            BiDiv => hir::BiDiv,
-            BiRem => hir::BiRem,
-            BiAnd => hir::BiAnd,
-            BiOr => hir::BiOr,
-            BiBitXor => hir::BiBitXor,
-            BiBitAnd => hir::BiBitAnd,
-            BiBitOr => hir::BiBitOr,
-            BiShl => hir::BiShl,
-            BiShr => hir::BiShr,
-            BiEq => hir::BiEq,
-            BiLt => hir::BiLt,
-            BiLe => hir::BiLe,
-            BiNe => hir::BiNe,
-            BiGe => hir::BiGe,
-            BiGt => hir::BiGt,
+            BinOpKind::Add => hir::BiAdd,
+            BinOpKind::Sub => hir::BiSub,
+            BinOpKind::Mul => hir::BiMul,
+            BinOpKind::Div => hir::BiDiv,
+            BinOpKind::Rem => hir::BiRem,
+            BinOpKind::And => hir::BiAnd,
+            BinOpKind::Or => hir::BiOr,
+            BinOpKind::BitXor => hir::BiBitXor,
+            BinOpKind::BitAnd => hir::BiBitAnd,
+            BinOpKind::BitOr => hir::BiBitOr,
+            BinOpKind::Shl => hir::BiShl,
+            BinOpKind::Shr => hir::BiShr,
+            BinOpKind::Eq => hir::BiEq,
+            BinOpKind::Lt => hir::BiLt,
+            BinOpKind::Le => hir::BiLe,
+            BinOpKind::Ne => hir::BiNe,
+            BinOpKind::Ge => hir::BiGe,
+            BinOpKind::Gt => hir::BiGt,
         },
         span: b.span,
     }
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 2b3ca63c26f..be6d65a01b5 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -10,7 +10,6 @@
 
 // The Rust abstract syntax tree.
 
-pub use self::BinOp_::*;
 pub use self::BlockCheckMode::*;
 pub use self::CaptureClause::*;
 pub use self::Decl_::*;
@@ -627,97 +626,99 @@ pub enum Mutability {
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
-pub enum BinOp_ {
+pub enum BinOpKind {
     /// The `+` operator (addition)
-    BiAdd,
+    Add,
     /// The `-` operator (subtraction)
-    BiSub,
+    Sub,
     /// The `*` operator (multiplication)
-    BiMul,
+    Mul,
     /// The `/` operator (division)
-    BiDiv,
+    Div,
     /// The `%` operator (modulus)
-    BiRem,
+    Rem,
     /// The `&&` operator (logical and)
-    BiAnd,
+    And,
     /// The `||` operator (logical or)
-    BiOr,
+    Or,
     /// The `^` operator (bitwise xor)
-    BiBitXor,
+    BitXor,
     /// The `&` operator (bitwise and)
-    BiBitAnd,
+    BitAnd,
     /// The `|` operator (bitwise or)
-    BiBitOr,
+    BitOr,
     /// The `<<` operator (shift left)
-    BiShl,
+    Shl,
     /// The `>>` operator (shift right)
-    BiShr,
+    Shr,
     /// The `==` operator (equality)
-    BiEq,
+    Eq,
     /// The `<` operator (less than)
-    BiLt,
+    Lt,
     /// The `<=` operator (less than or equal to)
-    BiLe,
+    Le,
     /// The `!=` operator (not equal to)
-    BiNe,
+    Ne,
     /// The `>=` operator (greater than or equal to)
-    BiGe,
+    Ge,
     /// The `>` operator (greater than)
-    BiGt,
+    Gt,
 }
 
-impl BinOp_ {
+impl BinOpKind {
     pub fn to_string(&self) -> &'static str {
+        use self::BinOpKind::*;
         match *self {
-            BiAdd => "+",
-            BiSub => "-",
-            BiMul => "*",
-            BiDiv => "/",
-            BiRem => "%",
-            BiAnd => "&&",
-            BiOr => "||",
-            BiBitXor => "^",
-            BiBitAnd => "&",
-            BiBitOr => "|",
-            BiShl => "<<",
-            BiShr => ">>",
-            BiEq => "==",
-            BiLt => "<",
-            BiLe => "<=",
-            BiNe => "!=",
-            BiGe => ">=",
-            BiGt => ">"
+            Add => "+",
+            Sub => "-",
+            Mul => "*",
+            Div => "/",
+            Rem => "%",
+            And => "&&",
+            Or => "||",
+            BitXor => "^",
+            BitAnd => "&",
+            BitOr => "|",
+            Shl => "<<",
+            Shr => ">>",
+            Eq => "==",
+            Lt => "<",
+            Le => "<=",
+            Ne => "!=",
+            Ge => ">=",
+            Gt => ">",
         }
     }
     pub fn lazy(&self) -> bool {
         match *self {
-            BiAnd | BiOr => true,
+            BinOpKind::And | BinOpKind::Or => true,
             _ => false
         }
     }
 
     pub fn is_shift(&self) -> bool {
         match *self {
-            BiShl | BiShr => true,
+            BinOpKind::Shl | BinOpKind::Shr => true,
             _ => false
         }
     }
     pub fn is_comparison(&self) -> bool {
+        use self::BinOpKind::*;
         match *self {
-            BiEq | BiLt | BiLe | BiNe | BiGt | BiGe =>
+            Eq | Lt | Le | Ne | Gt | Ge =>
             true,
-            BiAnd | BiOr | BiAdd | BiSub | BiMul | BiDiv | BiRem |
-            BiBitXor | BiBitAnd | BiBitOr | BiShl | BiShr =>
+            And | Or | Add | Sub | Mul | Div | Rem |
+            BitXor | BitAnd | BitOr | Shl | Shr =>
             false,
         }
     }
     /// Returns `true` if the binary operator takes its arguments by value
     pub fn is_by_value(&self) -> bool {
-        !BinOp_::is_comparison(self)
+        !self.is_comparison()
     }
 }
 
-pub type BinOp = Spanned<BinOp_>;
+pub type BinOp = Spanned<BinOpKind>;
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
 pub enum UnOp {
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index 2ce2e7f71f3..a5f6454cb38 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -116,7 +116,7 @@ pub trait AstBuilder {
     fn expr_ident(&self, span: Span, id: ast::Ident) -> P<ast::Expr>;
 
     fn expr_self(&self, span: Span) -> P<ast::Expr>;
-    fn expr_binary(&self, sp: Span, op: ast::BinOp_,
+    fn expr_binary(&self, sp: Span, op: ast::BinOpKind,
                    lhs: P<ast::Expr>, rhs: P<ast::Expr>) -> P<ast::Expr>;
     fn expr_deref(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
     fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P<ast::Expr>) -> P<ast::Expr>;
@@ -605,7 +605,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
         self.expr_ident(span, special_idents::self_)
     }
 
-    fn expr_binary(&self, sp: Span, op: ast::BinOp_,
+    fn expr_binary(&self, sp: Span, op: ast::BinOpKind,
                    lhs: P<ast::Expr>, rhs: P<ast::Expr>) -> P<ast::Expr> {
         self.expr(sp, ast::ExprBinary(Spanned { node: op, span: sp }, lhs, rhs))
     }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index c174e35d93b..d6d0a35f2ce 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -13,13 +13,13 @@ pub use self::PathParsingMode::*;
 use abi;
 use ast::BareFnTy;
 use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
-use ast::{Public, Unsafety, UnOp};
-use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindingMode};
-use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, BiLt, Block};
+use ast::{Public, Unsafety};
+use ast::{Mod, Arg, Arm, Attribute, BindingMode};
+use ast::Block;
 use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause};
 use ast::{Constness, ConstTraitItem, Crate, CrateConfig};
 use ast::{Decl, DeclItem, DeclLocal, DefaultBlock, DefaultReturn};
-use ast::{BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf};
+use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf};
 use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
 use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox};
 use ast::{ExprBreak, ExprCall, ExprCast, ExprInPlace};
@@ -38,14 +38,14 @@ use ast::{LitBool, LitChar, LitByte, LitByteStr};
 use ast::{LitStr, LitInt, Local};
 use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
 use ast::{MutImmutable, MutMutable, Mac_};
-use ast::{MutTy, BiMul, Mutability};
+use ast::{MutTy, Mutability};
 use ast::{NamedField, NoReturn};
 use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange};
 use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild};
 use ast::{PolyTraitRef, QSelf};
-use ast::{Return, BiShl, BiShr, Stmt, StmtDecl};
+use ast::{Return, Stmt, StmtDecl};
 use ast::{StmtExpr, StmtSemi, StmtMac, VariantData, StructField};
-use ast::{BiSub, StrStyle};
+use ast::StrStyle;
 use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue};
 use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
 use ast::{Ty, Ty_, TypeBinding, TyMac};
@@ -57,6 +57,7 @@ use ast::{UnnamedField, UnsafeBlock};
 use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
 use ast::{Visibility, WhereClause};
 use attr::{ThinAttributes, ThinAttributesExt, AttributesExt};
+use ast::{BinOpKind, UnOp};
 use ast;
 use ast_util::{self, ident_to_path};
 use codemap::{self, Span, BytePos, Spanned, spanned, mk_sp, CodeMap};
@@ -2925,16 +2926,16 @@ impl<'a> Parser<'a> {
                     self.mk_expr(lhs_span.lo, rhs.span.hi, ExprInPlace(lhs, rhs), None),
                 AssocOp::AssignOp(k) => {
                     let aop = match k {
-                        token::Plus =>    BiAdd,
-                        token::Minus =>   BiSub,
-                        token::Star =>    BiMul,
-                        token::Slash =>   BiDiv,
-                        token::Percent => BiRem,
-                        token::Caret =>   BiBitXor,
-                        token::And =>     BiBitAnd,
-                        token::Or =>      BiBitOr,
-                        token::Shl =>     BiShl,
-                        token::Shr =>     BiShr
+                        token::Plus =>    BinOpKind::Add,
+                        token::Minus =>   BinOpKind::Sub,
+                        token::Star =>    BinOpKind::Mul,
+                        token::Slash =>   BinOpKind::Div,
+                        token::Percent => BinOpKind::Rem,
+                        token::Caret =>   BinOpKind::BitXor,
+                        token::And =>     BinOpKind::BitAnd,
+                        token::Or =>      BinOpKind::BitOr,
+                        token::Shl =>     BinOpKind::Shl,
+                        token::Shr =>     BinOpKind::Shr,
                     };
                     let (lhs_span, rhs_span) = (lhs_span, rhs.span);
                     let aopexpr = self.mk_assign_op(codemap::respan(cur_op_span, aop), lhs, rhs);
@@ -2961,7 +2962,7 @@ impl<'a> Parser<'a> {
                 let op_span = mk_sp(op.span.lo, self.span.hi);
                 let mut err = self.diagnostic().struct_span_err(op_span,
                     "chained comparison operators require parentheses");
-                if op.node == BiLt && *outer_op == AssocOp::Greater {
+                if op.node == BinOpKind::Lt && *outer_op == AssocOp::Greater {
                     err.fileline_help(op_span,
                         "use `::<...>` instead of `<...>` if you meant to specify type arguments");
                 }
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 220d0aff2e3..7d1b78b632f 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -15,7 +15,7 @@ pub use self::IdentStyle::*;
 pub use self::Lit::*;
 pub use self::Token::*;
 
-use ast;
+use ast::{self, BinOpKind};
 use ext::mtwt;
 use ptr::P;
 use util::interner::{RcStr, StrInterner};
@@ -264,26 +264,26 @@ impl Token {
     }
 
     /// Maps a token to its corresponding binary operator.
-    pub fn to_binop(&self) -> Option<ast::BinOp_> {
+    pub fn to_binop(&self) -> Option<BinOpKind> {
         match *self {
-            BinOp(Star)     => Some(ast::BiMul),
-            BinOp(Slash)    => Some(ast::BiDiv),
-            BinOp(Percent)  => Some(ast::BiRem),
-            BinOp(Plus)     => Some(ast::BiAdd),
-            BinOp(Minus)    => Some(ast::BiSub),
-            BinOp(Shl)      => Some(ast::BiShl),
-            BinOp(Shr)      => Some(ast::BiShr),
-            BinOp(And)      => Some(ast::BiBitAnd),
-            BinOp(Caret)    => Some(ast::BiBitXor),
-            BinOp(Or)       => Some(ast::BiBitOr),
-            Lt              => Some(ast::BiLt),
-            Le              => Some(ast::BiLe),
-            Ge              => Some(ast::BiGe),
-            Gt              => Some(ast::BiGt),
-            EqEq            => Some(ast::BiEq),
-            Ne              => Some(ast::BiNe),
-            AndAnd          => Some(ast::BiAnd),
-            OrOr            => Some(ast::BiOr),
+            BinOp(Star)     => Some(BinOpKind::Mul),
+            BinOp(Slash)    => Some(BinOpKind::Div),
+            BinOp(Percent)  => Some(BinOpKind::Rem),
+            BinOp(Plus)     => Some(BinOpKind::Add),
+            BinOp(Minus)    => Some(BinOpKind::Sub),
+            BinOp(Shl)      => Some(BinOpKind::Shl),
+            BinOp(Shr)      => Some(BinOpKind::Shr),
+            BinOp(And)      => Some(BinOpKind::BitAnd),
+            BinOp(Caret)    => Some(BinOpKind::BitXor),
+            BinOp(Or)       => Some(BinOpKind::BitOr),
+            Lt              => Some(BinOpKind::Lt),
+            Le              => Some(BinOpKind::Le),
+            Ge              => Some(BinOpKind::Ge),
+            Gt              => Some(BinOpKind::Gt),
+            EqEq            => Some(BinOpKind::Eq),
+            Ne              => Some(BinOpKind::Ne),
+            AndAnd          => Some(BinOpKind::And),
+            OrOr            => Some(BinOpKind::Or),
             _               => None,
         }
     }
diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs
index 87ef96d87ff..6fb81bb6a76 100644
--- a/src/libsyntax/util/parser.rs
+++ b/src/libsyntax/util/parser.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 use parse::token::{Token, BinOpToken, keywords};
-use ast;
+use ast::BinOpKind;
 
 /// Associative operator with precedence.
 ///
@@ -108,28 +108,28 @@ impl AssocOp {
         }
     }
 
-    /// Create a new AssocOp from ast::BinOp_.
-    pub fn from_ast_binop(op: ast::BinOp_) -> Self {
+    /// Create a new AssocOp from ast::BinOpKind.
+    pub fn from_ast_binop(op: BinOpKind) -> Self {
         use self::AssocOp::*;
         match op {
-            ast::BiLt => Less,
-            ast::BiGt => Greater,
-            ast::BiLe => LessEqual,
-            ast::BiGe => GreaterEqual,
-            ast::BiEq => Equal,
-            ast::BiNe => NotEqual,
-            ast::BiMul => Multiply,
-            ast::BiDiv => Divide,
-            ast::BiRem => Modulus,
-            ast::BiAdd => Add,
-            ast::BiSub => Subtract,
-            ast::BiShl => ShiftLeft,
-            ast::BiShr => ShiftRight,
-            ast::BiBitAnd => BitAnd,
-            ast::BiBitXor => BitXor,
-            ast::BiBitOr => BitOr,
-            ast::BiAnd => LAnd,
-            ast::BiOr => LOr
+            BinOpKind::Lt => Less,
+            BinOpKind::Gt => Greater,
+            BinOpKind::Le => LessEqual,
+            BinOpKind::Ge => GreaterEqual,
+            BinOpKind::Eq => Equal,
+            BinOpKind::Ne => NotEqual,
+            BinOpKind::Mul => Multiply,
+            BinOpKind::Div => Divide,
+            BinOpKind::Rem => Modulus,
+            BinOpKind::Add => Add,
+            BinOpKind::Sub => Subtract,
+            BinOpKind::Shl => ShiftLeft,
+            BinOpKind::Shr => ShiftRight,
+            BinOpKind::BitAnd => BitAnd,
+            BinOpKind::BitXor => BitXor,
+            BinOpKind::BitOr => BitOr,
+            BinOpKind::And => LAnd,
+            BinOpKind::Or => LOr
         }
     }
 
@@ -185,27 +185,27 @@ impl AssocOp {
         }
     }
 
-    pub fn to_ast_binop(&self) -> Option<ast::BinOp_> {
+    pub fn to_ast_binop(&self) -> Option<BinOpKind> {
         use self::AssocOp::*;
         match *self {
-            Less => Some(ast::BiLt),
-            Greater => Some(ast::BiGt),
-            LessEqual => Some(ast::BiLe),
-            GreaterEqual => Some(ast::BiGe),
-            Equal => Some(ast::BiEq),
-            NotEqual => Some(ast::BiNe),
-            Multiply => Some(ast::BiMul),
-            Divide => Some(ast::BiDiv),
-            Modulus => Some(ast::BiRem),
-            Add => Some(ast::BiAdd),
-            Subtract => Some(ast::BiSub),
-            ShiftLeft => Some(ast::BiShl),
-            ShiftRight => Some(ast::BiShr),
-            BitAnd => Some(ast::BiBitAnd),
-            BitXor => Some(ast::BiBitXor),
-            BitOr => Some(ast::BiBitOr),
-            LAnd => Some(ast::BiAnd),
-            LOr => Some(ast::BiOr),
+            Less => Some(BinOpKind::Lt),
+            Greater => Some(BinOpKind::Gt),
+            LessEqual => Some(BinOpKind::Le),
+            GreaterEqual => Some(BinOpKind::Ge),
+            Equal => Some(BinOpKind::Eq),
+            NotEqual => Some(BinOpKind::Ne),
+            Multiply => Some(BinOpKind::Mul),
+            Divide => Some(BinOpKind::Div),
+            Modulus => Some(BinOpKind::Rem),
+            Add => Some(BinOpKind::Add),
+            Subtract => Some(BinOpKind::Sub),
+            ShiftLeft => Some(BinOpKind::Shl),
+            ShiftRight => Some(BinOpKind::Shr),
+            BitAnd => Some(BinOpKind::BitAnd),
+            BitXor => Some(BinOpKind::BitXor),
+            BitOr => Some(BinOpKind::BitOr),
+            LAnd => Some(BinOpKind::And),
+            LOr => Some(BinOpKind::Or),
             Inplace | Assign | AssignOp(_) | As | DotDot | Colon => None
         }
     }
diff --git a/src/libsyntax_ext/deriving/cmp/ord.rs b/src/libsyntax_ext/deriving/cmp/ord.rs
index 95a5d184d0e..2fa847ee430 100644
--- a/src/libsyntax_ext/deriving/cmp/ord.rs
+++ b/src/libsyntax_ext/deriving/cmp/ord.rs
@@ -11,8 +11,7 @@
 use deriving::generic::*;
 use deriving::generic::ty::*;
 
-use syntax::ast;
-use syntax::ast::{MetaItem, Expr};
+use syntax::ast::{MetaItem, Expr, BinOpKind, self};
 use syntax::codemap::Span;
 use syntax::ext::base::{ExtCtxt, Annotatable};
 use syntax::ext::build::AstBuilder;
@@ -116,7 +115,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
 
             let assign = cx.stmt_let(span, false, test_id, new);
 
-            let cond = cx.expr_binary(span, ast::BiEq,
+            let cond = cx.expr_binary(span, BinOpKind::Eq,
                                       cx.expr_ident(span, test_id),
                                       cx.expr_path(equals_path.clone()));
             let if_ = cx.expr_if(span,
diff --git a/src/libsyntax_ext/deriving/cmp/partial_eq.rs b/src/libsyntax_ext/deriving/cmp/partial_eq.rs
index 29be5a7ddc3..0150a073b07 100644
--- a/src/libsyntax_ext/deriving/cmp/partial_eq.rs
+++ b/src/libsyntax_ext/deriving/cmp/partial_eq.rs
@@ -11,7 +11,7 @@
 use deriving::generic::*;
 use deriving::generic::ty::*;
 
-use syntax::ast::{MetaItem, Expr, self};
+use syntax::ast::{MetaItem, Expr, BinOpKind};
 use syntax::codemap::Span;
 use syntax::ext::base::{ExtCtxt, Annotatable};
 use syntax::ext::build::AstBuilder;
@@ -35,9 +35,9 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
                     _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`")
                 };
 
-                let eq = cx.expr_binary(span, ast::BiEq, self_f, other_f.clone());
+                let eq = cx.expr_binary(span, BinOpKind::Eq, self_f, other_f.clone());
 
-                cx.expr_binary(span, ast::BiAnd, subexpr, eq)
+                cx.expr_binary(span, BinOpKind::And, subexpr, eq)
             },
             cx.expr_bool(span, true),
             Box::new(|cx, span, _, _| cx.expr_bool(span, false)),
@@ -52,9 +52,9 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
                     _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`")
                 };
 
-                let eq = cx.expr_binary(span, ast::BiNe, self_f, other_f.clone());
+                let eq = cx.expr_binary(span, BinOpKind::Ne, self_f, other_f.clone());
 
-                cx.expr_binary(span, ast::BiOr, subexpr, eq)
+                cx.expr_binary(span, BinOpKind::Or, subexpr, eq)
             },
             cx.expr_bool(span, false),
             Box::new(|cx, span, _, _| cx.expr_bool(span, true)),
diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs
index 4c10a3a31d0..e857f7d52f9 100644
--- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs
+++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs
@@ -13,8 +13,7 @@ pub use self::OrderingOp::*;
 use deriving::generic::*;
 use deriving::generic::ty::*;
 
-use syntax::ast;
-use syntax::ast::{MetaItem, Expr};
+use syntax::ast::{MetaItem, Expr, BinOpKind, self};
 use syntax::codemap::Span;
 use syntax::ext::base::{ExtCtxt, Annotatable};
 use syntax::ext::build::AstBuilder;
@@ -161,7 +160,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
 
             let assign = cx.stmt_let(span, false, test_id, new);
 
-            let cond = cx.expr_binary(span, ast::BiEq,
+            let cond = cx.expr_binary(span, BinOpKind::Eq,
                                       cx.expr_ident(span, test_id),
                                       equals_expr.clone());
             let if_ = cx.expr_if(span,
@@ -183,7 +182,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
 /// Strict inequality.
 fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt,
          span: Span, substr: &Substructure) -> P<Expr> {
-    let op = if less {ast::BiLt} else {ast::BiGt};
+    let op = if less { BinOpKind::Lt } else { BinOpKind::Gt };
     cs_fold(
         false, // need foldr,
         |cx, span, subexpr, self_f, other_fs| {
@@ -214,8 +213,8 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt,
             let not_cmp = cx.expr_unary(span, ast::UnOp::Not,
                                         cx.expr_binary(span, op, other_f.clone(), self_f));
 
-            let and = cx.expr_binary(span, ast::BiAnd, not_cmp, subexpr);
-            cx.expr_binary(span, ast::BiOr, cmp, and)
+            let and = cx.expr_binary(span, BinOpKind::And, not_cmp, subexpr);
+            cx.expr_binary(span, BinOpKind::Or, cmp, and)
         },
         cx.expr_bool(span, equal),
         Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| {
diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs
index 3af701739b4..9eb516cd07a 100644
--- a/src/libsyntax_ext/deriving/generic/mod.rs
+++ b/src/libsyntax_ext/deriving/generic/mod.rs
@@ -194,8 +194,7 @@ use std::vec;
 
 use syntax::abi::Abi;
 use syntax::abi;
-use syntax::ast;
-use syntax::ast::{EnumDef, Expr, Ident, Generics, VariantData};
+use syntax::ast::{EnumDef, Expr, Ident, Generics, VariantData, BinOpKind, self};
 use syntax::ast_util;
 use syntax::attr;
 use syntax::attr::AttrMetaMethods;
@@ -1279,8 +1278,9 @@ impl<'a> MethodDef<'a> {
                     Some(first) => {
                         let first_expr = cx.expr_ident(sp, first);
                         let id = cx.expr_ident(sp, ident);
-                        let test = cx.expr_binary(sp, ast::BiEq, first_expr, id);
-                        discriminant_test = cx.expr_binary(sp, ast::BiAnd, discriminant_test, test)
+                        let test = cx.expr_binary(sp, BinOpKind::Eq, first_expr, id);
+                        discriminant_test = cx.expr_binary(sp, BinOpKind::And,
+                                                           discriminant_test, test)
                     }
                     None => {
                         first_ident = Some(ident);
diff --git a/src/test/auxiliary/custom_derive_plugin.rs b/src/test/auxiliary/custom_derive_plugin.rs
index a3f42edbed2..5f0ef4de491 100644
--- a/src/test/auxiliary/custom_derive_plugin.rs
+++ b/src/test/auxiliary/custom_derive_plugin.rs
@@ -62,7 +62,7 @@ fn expand(cx: &mut ExtCtxt,
                     let zero = cx.expr_isize(span, 0);
                     cs_fold(false,
                             |cx, span, subexpr, field, _| {
-                                cx.expr_binary(span, ast::BiAdd, subexpr,
+                                cx.expr_binary(span, ast::BinOpKind::Add, subexpr,
                                     cx.expr_method_call(span, field,
                                         token::str_to_ident("total_sum"), vec![]))
                             },
diff --git a/src/test/auxiliary/custom_derive_plugin_attr.rs b/src/test/auxiliary/custom_derive_plugin_attr.rs
index fe12d3b1f08..ba216289fd4 100644
--- a/src/test/auxiliary/custom_derive_plugin_attr.rs
+++ b/src/test/auxiliary/custom_derive_plugin_attr.rs
@@ -81,7 +81,7 @@ fn totalsum_substructure(cx: &mut ExtCtxt, trait_span: Span,
         if item.attrs.iter().find(|a| a.check_name("ignore")).is_some() {
             acc
         } else {
-            cx.expr_binary(item.span, ast::BiAdd, acc,
+            cx.expr_binary(item.span, ast::BinOpKind::Add, acc,
                            cx.expr_method_call(item.span,
                                                item.self_.clone(),
                                                substr.method_ident,