Skip to content

try to reduce bajillion test warnings #22567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#![feature(unboxed_closures)]
#![feature(unsafe_no_drop_flag)]
#![feature(core)]
#![cfg_attr(test, feature(test, alloc, rustc_private))]
#![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")),
feature(libc))]

Expand Down
28 changes: 14 additions & 14 deletions src/libcoretest/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,84 +170,84 @@ mod u32 {
use test::Bencher;
use core::fmt::radix;
use std::rand::{weak_rng, Rng};
use std::old_io::util::NullWriter;
use std::io::{Write, sink};

#[bench]
fn format_bin(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:b}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{:b}", rng.gen::<u32>()) })
}

#[bench]
fn format_oct(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:o}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{:o}", rng.gen::<u32>()) })
}

#[bench]
fn format_dec(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{}", rng.gen::<u32>()) })
}

#[bench]
fn format_hex(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:x}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{:x}", rng.gen::<u32>()) })
}

#[bench]
fn format_show(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:?}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{:?}", rng.gen::<u32>()) })
}

#[bench]
fn format_base_36(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{}", radix(rng.gen::<u32>(), 36)) })
b.iter(|| { write!(&mut sink(), "{}", radix(rng.gen::<u32>(), 36)) })
}
}

mod i32 {
use test::Bencher;
use core::fmt::radix;
use std::rand::{weak_rng, Rng};
use std::old_io::util::NullWriter;
use std::io::{Write, sink};

#[bench]
fn format_bin(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:b}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{:b}", rng.gen::<i32>()) })
}

#[bench]
fn format_oct(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:o}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{:o}", rng.gen::<i32>()) })
}

#[bench]
fn format_dec(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{}", rng.gen::<i32>()) })
}

#[bench]
fn format_hex(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:x}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{:x}", rng.gen::<i32>()) })
}

#[bench]
fn format_show(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:?}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{:?}", rng.gen::<i32>()) })
}

#[bench]
fn format_base_36(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{}", radix(rng.gen::<i32>(), 36)) })
b.iter(|| { write!(&mut sink(), "{}", radix(rng.gen::<i32>(), 36)) })
}
}
16 changes: 8 additions & 8 deletions src/libcoretest/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn test_iterator_chain() {
let xs = [0, 1, 2, 3, 4, 5];
let ys = [30, 40, 50, 60];
let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60];
let mut it = xs.iter().chain(ys.iter());
let it = xs.iter().chain(ys.iter());
let mut i = 0;
for &x in it {
assert_eq!(x, expected[i]);
Expand All @@ -91,7 +91,7 @@ fn test_iterator_chain() {
assert_eq!(i, expected.len());

let ys = count(30, 10).take(4);
let mut it = xs.iter().cloned().chain(ys);
let it = xs.iter().cloned().chain(ys);
let mut i = 0;
for x in it {
assert_eq!(x, expected[i]);
Expand All @@ -110,7 +110,7 @@ fn test_filter_map() {
#[test]
fn test_iterator_enumerate() {
let xs = [0, 1, 2, 3, 4, 5];
let mut it = xs.iter().enumerate();
let it = xs.iter().enumerate();
for (i, &x) in it {
assert_eq!(i, x);
}
Expand Down Expand Up @@ -152,7 +152,7 @@ fn test_iterator_peekable() {
fn test_iterator_take_while() {
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
let ys = [0, 1, 2, 3, 5, 13];
let mut it = xs.iter().take_while(|&x| *x < 15);
let it = xs.iter().take_while(|&x| *x < 15);
let mut i = 0;
for x in it {
assert_eq!(*x, ys[i]);
Expand All @@ -165,7 +165,7 @@ fn test_iterator_take_while() {
fn test_iterator_skip_while() {
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
let ys = [15, 16, 17, 19];
let mut it = xs.iter().skip_while(|&x| *x < 15);
let it = xs.iter().skip_while(|&x| *x < 15);
let mut i = 0;
for x in it {
assert_eq!(*x, ys[i]);
Expand Down Expand Up @@ -231,7 +231,7 @@ fn test_iterator_scan() {
let xs = [0, 1, 2, 3, 4];
let ys = [0f64, 1.0, 3.0, 6.0, 10.0];

let mut it = xs.iter().scan(0, add);
let it = xs.iter().scan(0, add);
let mut i = 0;
for x in it {
assert_eq!(x, ys[i]);
Expand All @@ -244,7 +244,7 @@ fn test_iterator_scan() {
fn test_iterator_flat_map() {
let xs = [0, 3, 6];
let ys = [0, 1, 2, 3, 4, 5, 6, 7, 8];
let mut it = xs.iter().flat_map(|&x| count(x, 1).take(3));
let it = xs.iter().flat_map(|&x| count(x, 1).take(3));
let mut i = 0;
for x in it {
assert_eq!(x, ys[i]);
Expand Down Expand Up @@ -279,7 +279,7 @@ fn test_unfoldr() {
}
}

let mut it = Unfold::new(0, count);
let it = Unfold::new(0, count);
let mut i = 0;
for counted in it {
assert_eq!(counted, i);
Expand Down
9 changes: 9 additions & 0 deletions src/libcoretest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
#![feature(int_uint)]
#![feature(unboxed_closures)]
#![feature(unsafe_destructor)]
#![feature(core)]
#![feature(test)]
#![feature(rand)]
#![feature(unicode)]
#![feature(std_misc)]
#![feature(libc)]
#![feature(hash)]
#![feature(io)]
#![feature(collections)]
#![allow(deprecated)] // rand

extern crate core;
Expand Down
2 changes: 2 additions & 0 deletions src/librand/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#![deprecated(reason = "use the crates.io `rand` library instead",
since = "1.0.0-alpha")]

#![cfg_attr(test, feature(test, rand))]

#![allow(deprecated)]

#[macro_use]
Expand Down
2 changes: 2 additions & 0 deletions src/librbml/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#![feature(rustc_private)]
#![feature(staged_api)]

#![cfg_attr(test, feature(test))]

extern crate serialize;
#[macro_use] extern crate log;

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ impl DefaultResizePolicy {

#[test]
fn test_resize_policy() {
use prelude::v1::*;
let rp = DefaultResizePolicy;
for n in 0..1000 {
assert!(rp.min_capacity(rp.usable_capacity(n)) <= n);
Expand Down Expand Up @@ -2256,6 +2255,7 @@ mod test_map {

#[test]
fn test_entry_take_doesnt_corrupt() {
#![allow(deprecated)] //rand
// Test for #19292
fn check(m: &HashMap<isize, ()>) {
for k in m.keys() {
Expand Down
6 changes: 4 additions & 2 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,8 @@ pub fn set_permissions<P: AsPath + ?Sized>(path: &P, perm: Permissions)

#[cfg(test)]
mod tests {
#![allow(deprecated)] //rand

use prelude::v1::*;
use io::prelude::*;

Expand Down Expand Up @@ -1035,7 +1037,7 @@ mod tests {
let msg = msg_str.as_bytes();
check!(w.write(msg));
}
let mut files = check!(fs::read_dir(dir));
let files = check!(fs::read_dir(dir));
let mut mem = [0u8; 4];
for f in files {
let f = f.unwrap().path();
Expand Down Expand Up @@ -1065,7 +1067,7 @@ mod tests {
check!(fs::create_dir_all(dir2));
check!(File::create(&dir2.join("14")));

let mut files = check!(fs::walk_dir(dir));
let files = check!(fs::walk_dir(dir));
let mut cur = [0u8; 2];
for f in files {
let f = f.unwrap().path();
Expand Down
7 changes: 3 additions & 4 deletions src/libstd/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ mod tests {
assert_eq!(*writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7, 8]);

writer.write(&[9, 10, 11]).unwrap();
let a: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
assert_eq!(*writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);

writer.flush().unwrap();
Expand Down Expand Up @@ -593,7 +592,7 @@ mod tests {
#[test]
fn test_lines() {
let in_buf = b"a\nb\nc";
let mut reader = BufReader::with_capacity(2, in_buf);
let reader = BufReader::with_capacity(2, in_buf);
let mut it = reader.lines();
assert_eq!(it.next(), Some(Ok("a".to_string())));
assert_eq!(it.next(), Some(Ok("b".to_string())));
Expand All @@ -618,14 +617,14 @@ mod tests {
#[test]
fn read_char_buffered() {
let buf = [195u8, 159u8];
let mut reader = BufReader::with_capacity(1, &buf[..]);
let reader = BufReader::with_capacity(1, &buf[..]);
assert_eq!(reader.chars().next(), Some(Ok('ß')));
}

#[test]
fn test_chars() {
let buf = [195u8, 159u8, b'a'];
let mut reader = BufReader::with_capacity(1, &buf[..]);
let reader = BufReader::with_capacity(1, &buf[..]);
let mut it = reader.chars();
assert_eq!(it.next(), Some(Ok('ß')));
assert_eq!(it.next(), Some(Ok('a')));
Expand Down
8 changes: 4 additions & 4 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,12 +869,12 @@ mod tests {

#[test]
fn split() {
let mut buf = Cursor::new(b"12");
let buf = Cursor::new(b"12");
let mut s = buf.split(b'3');
assert_eq!(s.next(), Some(Ok(vec![b'1', b'2'])));
assert_eq!(s.next(), None);

let mut buf = Cursor::new(b"1233");
let buf = Cursor::new(b"1233");
let mut s = buf.split(b'3');
assert_eq!(s.next(), Some(Ok(vec![b'1', b'2'])));
assert_eq!(s.next(), Some(Ok(vec![])));
Expand Down Expand Up @@ -902,12 +902,12 @@ mod tests {

#[test]
fn lines() {
let mut buf = Cursor::new(b"12");
let buf = Cursor::new(b"12");
let mut s = buf.lines();
assert_eq!(s.next(), Some(Ok("12".to_string())));
assert_eq!(s.next(), None);

let mut buf = Cursor::new(b"12\n\n");
let buf = Cursor::new(b"12\n\n");
let mut s = buf.lines();
assert_eq!(s.next(), Some(Ok("12".to_string())));
assert_eq!(s.next(), Some(Ok(String::new())));
Expand Down
7 changes: 3 additions & 4 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(hash)]
#![feature(int_uint)]
#![feature(lang_items)]
#![feature(libc)]
Expand All @@ -123,7 +122,7 @@
#![feature(unsafe_destructor)]
#![feature(unsafe_no_drop_flag)]
#![feature(macro_reexport)]
#![cfg_attr(test, feature(test))]
#![cfg_attr(test, feature(test, rustc_private, env))]

// Don't link to std. We are std.
#![feature(no_std)]
Expand Down Expand Up @@ -219,15 +218,15 @@ mod int_macros;
#[macro_use]
mod uint_macros;

#[path = "num/int.rs"] pub mod int;
#[path = "num/isize.rs"] pub mod isize;
pub use isize as int;
#[path = "num/i8.rs"] pub mod i8;
#[path = "num/i16.rs"] pub mod i16;
#[path = "num/i32.rs"] pub mod i32;
#[path = "num/i64.rs"] pub mod i64;

#[path = "num/uint.rs"] pub mod uint;
#[path = "num/usize.rs"] pub mod usize;
pub use usize as uint;
#[path = "num/u8.rs"] pub mod u8;
#[path = "num/u16.rs"] pub mod u16;
#[path = "num/u32.rs"] pub mod u32;
Expand Down
6 changes: 0 additions & 6 deletions src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,6 @@ mod tests {
}
}

pub fn socket_name(addr: SocketAddr) {
}

pub fn peer_name(addr: SocketAddr) {
}

#[test]
fn socket_and_peer_name_ip4() {
each_ip(&mut |addr| {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn base_port() -> u16 {
let cwd = env::current_dir().unwrap();
let dirs = ["32-opt", "32-nopt", "64-opt", "64-nopt", "64-opt-vg",
"all-opt", "snap3", "dist"];
dirs.iter().enumerate().find(|&(i, dir)| {
dirs.iter().enumerate().find(|&(_, dir)| {
cwd.as_str().unwrap().contains(dir)
}).map(|p| p.0).unwrap_or(0) as u16 * 1000 + 19600
}
22 changes: 0 additions & 22 deletions src/libstd/num/int.rs

This file was deleted.

Loading