rustc: Remove the bitwise not operator
This commit is contained in:
parent
7a066ba547
commit
dfdd6dbc54
@ -183,7 +183,6 @@ fn binop_to_str(binop op) -> str {
|
||||
tag unop {
|
||||
box(mutability);
|
||||
deref;
|
||||
bitnot;
|
||||
not;
|
||||
neg;
|
||||
}
|
||||
@ -195,7 +194,6 @@ fn unop_to_str(unop op) -> str {
|
||||
ret "@";
|
||||
}
|
||||
case (deref) {ret "*";}
|
||||
case (bitnot) {ret "~";}
|
||||
case (not) {ret "!";}
|
||||
case (neg) {ret "-";}
|
||||
}
|
||||
|
@ -1172,13 +1172,6 @@ fn parse_prefix_expr(&parser p) -> @ast::expr {
|
||||
ex = ast::expr_unary(ast::not, e, p.get_ann());
|
||||
}
|
||||
|
||||
case (token::TILDE) {
|
||||
p.bump();
|
||||
auto e = parse_prefix_expr(p);
|
||||
hi = e.span.hi;
|
||||
ex = ast::expr_unary(ast::bitnot, e, p.get_ann());
|
||||
}
|
||||
|
||||
case (token::BINOP(?b)) {
|
||||
alt (b) {
|
||||
case (token::MINUS) {
|
||||
|
@ -3388,11 +3388,6 @@ fn trans_unary(&@block_ctxt cx, ast::unop op,
|
||||
auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
|
||||
|
||||
alt (op) {
|
||||
case (ast::bitnot) {
|
||||
sub = autoderef(sub.bcx, sub.val,
|
||||
ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
|
||||
ret res(sub.bcx, sub.bcx.build.Not(sub.val));
|
||||
}
|
||||
case (ast::not) {
|
||||
sub = autoderef(sub.bcx, sub.val,
|
||||
ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
|
||||
|
@ -1580,6 +1580,16 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case (ast::not) {
|
||||
if (!type_is_integral(fcx, oper.span, oper_t) &&
|
||||
structure_of(fcx, oper.span, oper_t)
|
||||
!= ty::ty_bool) {
|
||||
fcx.ccx.tcx.sess.span_err(expr.span,
|
||||
#fmt("mismatched types: expected bool or \
|
||||
integer but found %s",
|
||||
ty_to_str(fcx.ccx.tcx, oper_t)));
|
||||
}
|
||||
}
|
||||
case (_) { oper_t = strip_boxes(fcx, expr.span, oper_t); }
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,7 @@ fn uint_bits() -> uint {
|
||||
}
|
||||
|
||||
fn create(uint nbits, bool init) -> t {
|
||||
auto elt = if (init) {
|
||||
~0u
|
||||
} else {
|
||||
0u
|
||||
};
|
||||
auto elt = if (init) { !0u } else { 0u };
|
||||
|
||||
auto storage = vec::init_elt_mut[uint](elt, nbits / uint_bits() + 1u);
|
||||
ret rec(storage = storage, nbits = nbits);
|
||||
@ -139,7 +135,7 @@ fn set_all(&t v) {
|
||||
|
||||
fn invert(&t v) {
|
||||
for each (uint i in uint::range(0u, vec::len(v.storage))) {
|
||||
v.storage.(i) = ~v.storage.(i);
|
||||
v.storage.(i) = !v.storage.(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +159,7 @@ fn set(&t v, uint i, bool x) {
|
||||
v.storage.(w) = if (x) {
|
||||
v.storage.(w) | flag
|
||||
} else {
|
||||
v.storage.(w) & ~flag
|
||||
v.storage.(w) & !flag
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ fn mk_sha1() -> sha1 {
|
||||
t = 0;
|
||||
while (t < 20) {
|
||||
temp = circular_shift(5u32, a)
|
||||
+ ((b & c) | ((~b) & d)) + e + w.(t) + k0;
|
||||
+ ((b & c) | ((!b) & d)) + e + w.(t) + k0;
|
||||
e = d;
|
||||
d = c;
|
||||
c = circular_shift(30u32, b);
|
||||
|
Loading…
Reference in New Issue
Block a user