Skip to content

Commit

Permalink
Fix warnings during tests
Browse files Browse the repository at this point in the history
The deny(warnings) attribute is now enabled for tests so we need to weed out
these warnings as well.
  • Loading branch information
alexcrichton committed Jan 26, 2016
1 parent 4b3c355 commit cb343c3
Show file tree
Hide file tree
Showing 24 changed files with 137 additions and 141 deletions.
1 change: 0 additions & 1 deletion src/liballoc/boxed_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use core::ops::Deref;
use core::result::Result::{Ok, Err};
use core::clone::Clone;

use std::boxed;
use std::boxed::Box;

#[test]
Expand Down
13 changes: 5 additions & 8 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,28 @@
#![feature(allocator)]
#![feature(box_syntax)]
#![feature(coerce_unsized)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(custom_attribute)]
#![feature(drop_in_place)]
#![feature(dropck_parametricity)]
#![feature(fundamental)]
#![feature(lang_items)]
#![feature(needs_allocator)]
#![feature(optin_builtin_traits)]
#![feature(placement_in_syntax)]
#![feature(placement_new_protocol)]
#![feature(raw)]
#![feature(shared)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![feature(unique)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(dropck_parametricity)]
#![feature(unsize)]
#![feature(drop_in_place)]
#![feature(fn_traits)]
#![feature(const_fn)]

#![feature(needs_allocator)]

// Issue# 30592: Systematically use alloc_system during stage0 since jemalloc
// might be unavailable or disabled
#![cfg_attr(stage0, feature(alloc_system))]

#![cfg_attr(not(test), feature(raw, fn_traits, placement_new_protocol))]
#![cfg_attr(test, feature(test, rustc_private, box_heap))]

#[cfg(stage0)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#![feature(unicode)]
#![feature(unique)]
#![feature(unsafe_no_drop_flag)]
#![cfg_attr(test, feature(clone_from_slice, rand, test))]
#![cfg_attr(test, feature(rand, test))]

#![no_std]

Expand Down
15 changes: 2 additions & 13 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,14 @@

// Many of the usings in this module are only used in the test configuration.
// It's cleaner to just turn off the unused_imports warning than to fix them.
#![allow(unused_imports)]
#![cfg_attr(test, allow(unused_imports, dead_code))]

use alloc::boxed::Box;
use core::clone::Clone;
use core::cmp::Ordering::{self, Greater, Less};
use core::cmp::{self, Ord, PartialEq};
use core::iter::Iterator;
use core::marker::Sized;
use core::cmp;
use core::mem::size_of;
use core::mem;
use core::ops::FnMut;
use core::option::Option::{self, Some, None};
use core::ptr;
use core::result::Result;
use core::slice as core_slice;

use borrow::{Borrow, BorrowMut, ToOwned};
Expand Down Expand Up @@ -136,12 +130,7 @@ pub use self::hack::to_vec;
// `test_permutations` test
mod hack {
use alloc::boxed::Box;
use core::clone::Clone;
#[cfg(test)]
use core::iter::Iterator;
use core::mem;
#[cfg(test)]
use core::option::Option::{Some, None};

#[cfg(test)]
use string::ToString;
Expand Down
4 changes: 0 additions & 4 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
// It's cleaner to just turn off the unused_imports warning than to fix them.
#![allow(unused_imports)]

use core::clone::Clone;
use core::iter::{Iterator, Extend};
use core::option::Option::{self, Some, None};
use core::result::Result;
use core::str as core_str;
use core::str::pattern::Pattern;
use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};
Expand Down
1 change: 0 additions & 1 deletion src/libcollectionstest/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

use std::cmp::Ordering::{Equal, Greater, Less};
use std::default::Default;
use std::mem;
use std::__rand::{Rng, thread_rng};
use std::rc::Rc;
Expand Down
2 changes: 1 addition & 1 deletion src/librand/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#![feature(custom_attribute)]
#![allow(unused_attributes)]

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

#![allow(deprecated)]

Expand Down
1 change: 0 additions & 1 deletion src/libserialize/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,6 @@ impl FromStr for Json {
mod tests {
extern crate test;
use self::Animal::*;
use self::DecodeEnum::*;
use self::test::Bencher;
use {Encodable, Decodable};
use super::Json::*;
Expand Down
14 changes: 12 additions & 2 deletions src/libstd/dynamic_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
reason = "API has not been scrutinized and is highly likely to \
either disappear or change",
issue = "27810")]
#![rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")]
#![allow(missing_docs)]
#![allow(deprecated)]

Expand All @@ -26,6 +25,11 @@ use env;
use ffi::{CString, OsString};
use path::{Path, PathBuf};

#[unstable(feature = "dynamic_lib",
reason = "API has not been scrutinized and is highly likely to \
either disappear or change",
issue = "27810")]
#[rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")]
pub struct DynamicLibrary {
handle: *mut u8
}
Expand All @@ -43,6 +47,11 @@ impl Drop for DynamicLibrary {
}
}

#[unstable(feature = "dynamic_lib",
reason = "API has not been scrutinized and is highly likely to \
either disappear or change",
issue = "27810")]
#[rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")]
impl DynamicLibrary {
/// Lazily open a dynamic library. When passed None it gives a
/// handle to the calling process
Expand Down Expand Up @@ -126,7 +135,6 @@ mod tests {
use prelude::v1::*;
use libc;
use mem;
use path::Path;

#[test]
#[cfg_attr(any(windows,
Expand Down Expand Up @@ -167,6 +175,8 @@ mod tests {
target_os = "openbsd"))]
#[allow(deprecated)]
fn test_errors_do_not_crash() {
use path::Path;

// Open /dev/null as a library to get an error, and make sure
// that only causes an error, and not a crash.
let path = Path::new("/dev/null");
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,8 @@ mod tests {

thread::spawn(|| {
let mut writer = BufWriter::new(PanicWriter);
writer.write(b"hello world");
writer.flush();
let _ = writer.write(b"hello world");
let _ = writer.flush();
}).join().err().unwrap();

assert_eq!(WRITES.load(Ordering::SeqCst), 1);
Expand Down
1 change: 1 addition & 0 deletions src/libstd/os/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub enum c_void {
}

#[cfg(test)]
#[allow(unused_imports)]
mod tests {
use any::TypeId;
use libc;
Expand Down
8 changes: 5 additions & 3 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3326,11 +3326,13 @@ mod tests {
"{:?}.ends_with({:?}), expected {:?}, got {:?}", $path1, $path2,
$ends_with, ends_with);

let relative_from = path1.relative_from(path2).map(|p| p.to_str().unwrap());
let relative_from = path1.strip_prefix(path2)
.map(|p| p.to_str().unwrap())
.ok();
let exp: Option<&str> = $relative_from;
assert!(relative_from == exp,
"{:?}.relative_from({:?}), expected {:?}, got {:?}", $path1, $path2,
exp, relative_from);
"{:?}.strip_prefix({:?}), expected {:?}, got {:?}",
$path1, $path2, exp, relative_from);
});
);

Expand Down
Loading

0 comments on commit cb343c3

Please sign in to comment.