diff options
| -rw-r--r-- | src/librustc/middle/const_eval.rs | 12 | ||||
| -rw-r--r-- | src/librustc_lint/builtin.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/trans/adt.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/trans/base.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/trans/context.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 4 |
7 files changed, 19 insertions, 9 deletions
diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index e3e5efc53c7..214ea163232 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -23,6 +23,7 @@ use middle::astconv_util::ast_ty_to_prim_ty; use syntax::ast::{self, Expr}; use syntax::codemap::Span; +use syntax::feature_gate; use syntax::parse::token::InternedString; use syntax::ptr::P; use syntax::{ast_map, ast_util, codemap}; @@ -594,7 +595,16 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, match try!(eval_const_expr_partial(tcx, &**inner, ety)) { const_float(f) => const_float(-f), const_int(n) => try!(const_int_checked_neg(n, e, expr_int_type)), - const_uint(n) => try!(const_uint_checked_neg(n, e, expr_uint_type)), + const_uint(i) => { + if !tcx.sess.features.borrow().negate_unsigned { + feature_gate::emit_feature_err( + &tcx.sess.parse_sess.span_diagnostic, + "negate_unsigned", + e.span, + "unary negation of unsigned integers may be removed in the future"); + } + const_uint(n) => try!(const_uint_checked_neg(n, e, expr_uint_type)), + } const_str(_) => signal!(e, NegateOnString), const_bool(_) => signal!(e, NegateOnBoolean), const_binary(_) => signal!(e, NegateOnBinary), diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index e7443af3013..cc22f8ff809 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -116,7 +116,7 @@ pub struct TypeLimits { impl TypeLimits { pub fn new() -> TypeLimits { TypeLimits { - negated_expr_id: -1, + negated_expr_id: !0, } } } diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index e32d8e2b9cf..fd1fff308df 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -830,7 +830,7 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr) let bits = machine::llbitsize_of_real(bcx.ccx(), llty); assert!(bits <= 64); let bits = bits as usize; - let mask = (-1u64 >> (64 - bits)) as Disr; + let mask = (!0u64 >> (64 - bits)) as Disr; // For a (max) discr of -1, max will be `-1 as usize`, which overflows. // However, that is fine here (it would still represent the full range), if (max.wrapping_add(1)) & mask == min & mask { diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 20677ab93fc..51db1430ae2 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -868,7 +868,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>( _ => unreachable!(), }; let minus_one = ICmp(bcx, llvm::IntEQ, rhs, - C_integral(llty, -1, false), debug_loc); + C_integral(llty, !0, false), debug_loc); with_cond(bcx, minus_one, |bcx| { let is_min = ICmp(bcx, llvm::IntEQ, lhs, C_integral(llty, min, true), debug_loc); @@ -1388,7 +1388,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>, common::validate_substs(param_substs); debug!("new_fn_ctxt(path={}, id={}, param_substs={})", - if id == -1 { + if id == !0 { "".to_string() } else { ccx.tcx().map.path_to_string(id).to_string() diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index 3542bcd081f..8919a386a45 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -459,7 +459,7 @@ impl<'tcx> LocalCrateContext<'tcx> { CrateContext { shared: shared, local: self, - index: -1 as usize, + index: !0 as usize, } } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ce1539c62f8..40390765dde 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -388,7 +388,7 @@ pub const CRATE_NODE_ID: NodeId = 0; /// When parsing and doing expansions, we initially give all AST nodes this AST /// node value. Then later, in the renumber pass, we renumber them to have /// small, positive ids. -pub const DUMMY_NODE_ID: NodeId = -1; +pub const DUMMY_NODE_ID: NodeId = !0; /// The AST represents all type param bounds as types. /// typeck::collect::compute_bounds matches these against diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 6a00fff1860..c2f2c51ed2c 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -278,9 +278,9 @@ pub struct ExpnInfo { #[derive(PartialEq, Eq, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Copy)] pub struct ExpnId(u32); -pub const NO_EXPANSION: ExpnId = ExpnId(-1); +pub const NO_EXPANSION: ExpnId = ExpnId(!0); // For code appearing from the command line -pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(-2); +pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(!1); impl ExpnId { pub fn from_llvm_cookie(cookie: c_uint) -> ExpnId { |
