Skip to content

Commit f86318d

Browse files
alexcrichtonpnkfelix
authored andcommitted
Test fixes and rebase conflicts, round 2
Conflicts: src/libcore/num/mod.rs
1 parent 07ff8ab commit f86318d

File tree

11 files changed

+19
-17
lines changed

11 files changed

+19
-17
lines changed

src/libcollectionstest/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ fn test_bytes_set_memory() {
10881088
#[should_panic]
10891089
fn test_overflow_does_not_cause_segfault() {
10901090
let mut v = vec![];
1091-
v.reserve_exact(-1);
1091+
v.reserve_exact(!0);
10921092
v.push(1);
10931093
v.push(2);
10941094
}
@@ -1097,7 +1097,7 @@ fn test_overflow_does_not_cause_segfault() {
10971097
#[should_panic]
10981098
fn test_overflow_does_not_cause_segfault_managed() {
10991099
let mut v = vec![Rc::new(1)];
1100-
v.reserve_exact(-1);
1100+
v.reserve_exact(!0);
11011101
v.push(Rc::new(2));
11021102
}
11031103

src/libcoretest/fmt/num.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ fn test_format_int_flags() {
125125
assert!(format!("{:>8x}", 10) == " a");
126126
assert!(format!("{:#08x}", 10) == "0x00000a");
127127
assert!(format!("{:08}", -10) == "-0000010");
128-
assert!(format!("{:x}", -1u8) == "ff");
129-
assert!(format!("{:X}", -1u8) == "FF");
130-
assert!(format!("{:b}", -1u8) == "11111111");
131-
assert!(format!("{:o}", -1u8) == "377");
132-
assert!(format!("{:#x}", -1u8) == "0xff");
133-
assert!(format!("{:#X}", -1u8) == "0xFF");
134-
assert!(format!("{:#b}", -1u8) == "0b11111111");
135-
assert!(format!("{:#o}", -1u8) == "0o377");
128+
assert!(format!("{:x}", !0u8) == "ff");
129+
assert!(format!("{:X}", !0u8) == "FF");
130+
assert!(format!("{:b}", !0u8) == "11111111");
131+
assert!(format!("{:o}", !0u8) == "377");
132+
assert!(format!("{:#x}", !0u8) == "0xff");
133+
assert!(format!("{:#X}", !0u8) == "0xFF");
134+
assert!(format!("{:#b}", !0u8) == "0b11111111");
135+
assert!(format!("{:#o}", !0u8) == "0o377");
136136
}
137137

138138
#[test]

src/liblibc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2865,7 +2865,7 @@ pub mod consts {
28652865
pub const MAP_FIXED : c_int = 0x0010;
28662866
pub const MAP_ANON : c_int = 0x0020;
28672867

2868-
pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
2868+
pub const MAP_FAILED : *mut c_void = !0 as *mut c_void;
28692869

28702870
pub const MCL_CURRENT : c_int = 0x0001;
28712871
pub const MCL_FUTURE : c_int = 0x0002;

src/librand/distributions/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ mod tests {
361361
}
362362
#[test] #[should_panic]
363363
fn test_weighted_choice_weight_overflows() {
364-
let x = (-1) as usize / 2; // x + x + 2 is the overflow
364+
let x = (!0) as usize / 2; // x + x + 2 is the overflow
365365
WeightedChoice::new(&mut [Weighted { weight: x, item: 0 },
366366
Weighted { weight: 1, item: 1 },
367367
Weighted { weight: x, item: 2 },

src/librustc/middle/const_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ pub fn const_int_checked_neg<'a>(
396396
pub fn const_uint_checked_neg<'a>(
397397
a: u64, _e: &'a Expr, _opt_ety: Option<UintTy>) -> EvalResult {
398398
// This always succeeds, and by definition, returns `(!a)+1`.
399-
Ok(const_uint(-a))
399+
Ok(const_uint((!a).wrapping_add(1)))
400400
}
401401

402402
macro_rules! overflow_checking_body {

src/libstd/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ mod tests {
946946
let mut read_stream = check!(File::open(filename));
947947
let mut read_buf = [0; 1028];
948948
let read_str = match check!(read_stream.read(&mut read_buf)) {
949-
-1|0 => panic!("shouldn't happen"),
949+
0 => panic!("shouldn't happen"),
950950
n => str::from_utf8(&read_buf[..n]).unwrap().to_string()
951951
};
952952
assert_eq!(read_str, message);

src/libstd/old_io/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ mod test {
970970
let mut read_stream = File::open_mode(filename, Open, Read);
971971
let mut read_buf = [0; 1028];
972972
let read_str = match check!(read_stream.read(&mut read_buf)) {
973-
-1|0 => panic!("shouldn't happen"),
973+
0 => panic!("shouldn't happen"),
974974
n => str::from_utf8(&read_buf[..n]).unwrap().to_string()
975975
};
976976
assert_eq!(read_str, message);

src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,7 @@ mod test {
30483048
#[test]
30493049
fn test_signed_int_to_string() {
30503050
let pos_int = ast::LitInt(42, ast::SignedIntLit(ast::TyI32, ast::Plus));
3051-
let neg_int = ast::LitInt((-42) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus));
3051+
let neg_int = ast::LitInt((!42 + 1) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus));
30523052
assert_eq!(format!("-{}", lit_to_string(&codemap::dummy_spanned(pos_int))),
30533053
lit_to_string(&codemap::dummy_spanned(neg_int)));
30543054
}

src/test/compile-fail/const-eval-overflow.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(negate_unsigned)]
1212

1313
#![allow(unused_imports)]
14+
#![feature(negate_unsigned)]
1415

1516
// Note: the relevant lint pass here runs before some of the constant
1617
// evaluation below (e.g. that performed by trans and llvm), so if you

src/test/compile-fail/lint-exceeding-bitshifts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#![deny(exceeding_bitshifts)]
1313
#![allow(unused_variables)]
1414
#![allow(dead_code)]
15-
#![feature(core)]
15+
#![feature(core, negate_unsigned)]
1616

1717
fn main() {
1818
let n = 1u8 << 7;

src/test/compile-fail/lint-type-limits.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#![feature(negate_unsigned)]
1212
#![allow(dead_code)]
13+
#![feature(negate_unsigned)]
1314

1415
// compile-flags: -D unused-comparisons
1516
fn main() { }

0 commit comments

Comments
 (0)