diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index f6342831143..698d82adff4 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -876,9 +876,9 @@ pub fn lower_constness(_lctx: &LoweringContext, c: Constness) -> hir::Constness pub fn lower_unop(_lctx: &LoweringContext, u: UnOp) -> hir::UnOp { match u { - UnDeref => hir::UnDeref, - UnNot => hir::UnNot, - UnNeg => hir::UnNeg, + UnOp::Deref => hir::UnDeref, + UnOp::Not => hir::UnNot, + UnOp::Neg => hir::UnNeg, } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 088f911ed8c..2b3ca63c26f 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -38,7 +38,6 @@ pub use self::TraitItem_::*; pub use self::Ty_::*; pub use self::TyParamBound::*; pub use self::UintTy::*; -pub use self::UnOp::*; pub use self::UnsafeSource::*; pub use self::ViewPath_::*; pub use self::Visibility::*; @@ -723,27 +722,27 @@ pub type BinOp = Spanned; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum UnOp { /// The `*` operator for dereferencing - UnDeref, + Deref, /// The `!` operator for logical inversion - UnNot, + Not, /// The `-` operator for negation - UnNeg + Neg, } impl UnOp { /// Returns `true` if the unary operator takes its argument by value pub fn is_by_value(u: UnOp) -> bool { match u { - UnNeg | UnNot => true, + UnOp::Neg | UnOp::Not => true, _ => false, } } pub fn to_string(op: UnOp) -> &'static str { match op { - UnDeref => "*", - UnNot => "!", - UnNeg => "-", + UnOp::Deref => "*", + UnOp::Not => "!", + UnOp::Neg => "-", } } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index a74c2340cec..2ce2e7f71f3 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -10,6 +10,7 @@ use abi; use ast::{Ident, Generics, Expr}; +use ast::UnOp; use ast; use attr; use codemap::{Span, respan, Spanned, DUMMY_SP, Pos}; @@ -610,7 +611,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn expr_deref(&self, sp: Span, e: P) -> P { - self.expr_unary(sp, ast::UnDeref, e) + self.expr_unary(sp, UnOp::Deref, e) } fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P) -> P { self.expr(sp, ast::ExprUnary(op, e)) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 82bfc26ee34..c174e35d93b 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}; +use ast::{Public, Unsafety, UnOp}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindingMode}; use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, BiLt, Block}; use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause}; use ast::{Constness, ConstTraitItem, Crate, CrateConfig}; use ast::{Decl, DeclItem, DeclLocal, DefaultBlock, DefaultReturn}; -use ast::{UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf}; +use ast::{BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf}; use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox}; use ast::{ExprBreak, ExprCall, ExprCast, ExprInPlace}; @@ -39,7 +39,7 @@ use ast::{LitStr, LitInt, Local}; use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces}; use ast::{MutImmutable, MutMutable, Mac_}; use ast::{MutTy, BiMul, Mutability}; -use ast::{NamedField, UnNeg, NoReturn, UnNot}; +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}; @@ -1608,7 +1608,7 @@ impl<'a> Parser<'a> { if minus_present { let minus_hi = self.last_span.hi; - let unary = self.mk_unary(UnNeg, expr); + let unary = self.mk_unary(UnOp::Neg, expr); Ok(self.mk_expr(minus_lo, minus_hi, unary, None)) } else { Ok(expr) @@ -2740,21 +2740,21 @@ impl<'a> Parser<'a> { let e = self.parse_prefix_expr(None); let (span, e) = try!(self.interpolated_or_expr_span(e)); hi = span.hi; - self.mk_unary(UnNot, e) + self.mk_unary(UnOp::Not, e) } token::BinOp(token::Minus) => { self.bump(); let e = self.parse_prefix_expr(None); let (span, e) = try!(self.interpolated_or_expr_span(e)); hi = span.hi; - self.mk_unary(UnNeg, e) + self.mk_unary(UnOp::Neg, e) } token::BinOp(token::Star) => { self.bump(); let e = self.parse_prefix_expr(None); let (span, e) = try!(self.interpolated_or_expr_span(e)); hi = span.hi; - self.mk_unary(UnDeref, e) + self.mk_unary(UnOp::Deref, e) } token::BinOp(token::And) | token::AndAnd => { try!(self.expect_and()); diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs index bd825e5c8df..4c10a3a31d0 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs @@ -211,7 +211,7 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, let cmp = cx.expr_binary(span, op, self_f.clone(), other_f.clone()); - let not_cmp = cx.expr_unary(span, ast::UnNot, + 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);