Skip to content

Commit 98dd376

Browse files
committed
fallout when bootstrapping rustc.
1 parent 3225b04 commit 98dd376

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

src/librustc/middle/const_eval.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use middle::astconv_util::ast_ty_to_prim_ty;
2323

2424
use syntax::ast::{self, Expr};
2525
use syntax::codemap::Span;
26+
use syntax::feature_gate;
2627
use syntax::parse::token::InternedString;
2728
use syntax::ptr::P;
2829
use syntax::{ast_map, ast_util, codemap};
@@ -594,7 +595,16 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
594595
match try!(eval_const_expr_partial(tcx, &**inner, ety)) {
595596
const_float(f) => const_float(-f),
596597
const_int(n) => try!(const_int_checked_neg(n, e, expr_int_type)),
597-
const_uint(n) => try!(const_uint_checked_neg(n, e, expr_uint_type)),
598+
const_uint(i) => {
599+
if !tcx.sess.features.borrow().negate_unsigned {
600+
feature_gate::emit_feature_err(
601+
&tcx.sess.parse_sess.span_diagnostic,
602+
"negate_unsigned",
603+
e.span,
604+
"unary negation of unsigned integers may be removed in the future");
605+
}
606+
const_uint(n) => try!(const_uint_checked_neg(n, e, expr_uint_type)),
607+
}
598608
const_str(_) => signal!(e, NegateOnString),
599609
const_bool(_) => signal!(e, NegateOnBoolean),
600610
const_binary(_) => signal!(e, NegateOnBinary),

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub struct TypeLimits {
116116
impl TypeLimits {
117117
pub fn new() -> TypeLimits {
118118
TypeLimits {
119-
negated_expr_id: -1,
119+
negated_expr_id: !0,
120120
}
121121
}
122122
}

src/librustc_trans/trans/adt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
830830
let bits = machine::llbitsize_of_real(bcx.ccx(), llty);
831831
assert!(bits <= 64);
832832
let bits = bits as usize;
833-
let mask = (-1u64 >> (64 - bits)) as Disr;
833+
let mask = (!0u64 >> (64 - bits)) as Disr;
834834
// For a (max) discr of -1, max will be `-1 as usize`, which overflows.
835835
// However, that is fine here (it would still represent the full range),
836836
if (max.wrapping_add(1)) & mask == min & mask {

src/librustc_trans/trans/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
868868
_ => unreachable!(),
869869
};
870870
let minus_one = ICmp(bcx, llvm::IntEQ, rhs,
871-
C_integral(llty, -1, false), debug_loc);
871+
C_integral(llty, !0, false), debug_loc);
872872
with_cond(bcx, minus_one, |bcx| {
873873
let is_min = ICmp(bcx, llvm::IntEQ, lhs,
874874
C_integral(llty, min, true), debug_loc);
@@ -1388,7 +1388,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
13881388
common::validate_substs(param_substs);
13891389

13901390
debug!("new_fn_ctxt(path={}, id={}, param_substs={})",
1391-
if id == -1 {
1391+
if id == !0 {
13921392
"".to_string()
13931393
} else {
13941394
ccx.tcx().map.path_to_string(id).to_string()

src/librustc_trans/trans/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ impl<'tcx> LocalCrateContext<'tcx> {
459459
CrateContext {
460460
shared: shared,
461461
local: self,
462-
index: -1 as usize,
462+
index: !0 as usize,
463463
}
464464
}
465465
}

src/libsyntax/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ pub const CRATE_NODE_ID: NodeId = 0;
388388
/// When parsing and doing expansions, we initially give all AST nodes this AST
389389
/// node value. Then later, in the renumber pass, we renumber them to have
390390
/// small, positive ids.
391-
pub const DUMMY_NODE_ID: NodeId = -1;
391+
pub const DUMMY_NODE_ID: NodeId = !0;
392392

393393
/// The AST represents all type param bounds as types.
394394
/// typeck::collect::compute_bounds matches these against

src/libsyntax/codemap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ pub struct ExpnInfo {
278278
#[derive(PartialEq, Eq, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Copy)]
279279
pub struct ExpnId(u32);
280280

281-
pub const NO_EXPANSION: ExpnId = ExpnId(-1);
281+
pub const NO_EXPANSION: ExpnId = ExpnId(!0);
282282
// For code appearing from the command line
283-
pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(-2);
283+
pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(!1);
284284

285285
impl ExpnId {
286286
pub fn from_llvm_cookie(cookie: c_uint) -> ExpnId {

0 commit comments

Comments
 (0)