[breaking-change] don't glob export ast::UnOp variants
This commit is contained in:
parent
060848c315
commit
f875f4c4c2
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<BinOp_>;
|
|||
#[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 => "-",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ast::Expr>) -> P<ast::Expr> {
|
||||
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<ast::Expr>) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprUnary(op, e))
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue