Skip to content

Commit cb343c3

Browse files
committed
Fix warnings during tests
The deny(warnings) attribute is now enabled for tests so we need to weed out these warnings as well.
1 parent 4b3c355 commit cb343c3

File tree

24 files changed

+137
-141
lines changed

24 files changed

+137
-141
lines changed

src/liballoc/boxed_test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use core::ops::Deref;
1515
use core::result::Result::{Ok, Err};
1616
use core::clone::Clone;
1717

18-
use std::boxed;
1918
use std::boxed::Box;
2019

2120
#[test]

src/liballoc/lib.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -75,31 +75,28 @@
7575
#![feature(allocator)]
7676
#![feature(box_syntax)]
7777
#![feature(coerce_unsized)]
78+
#![feature(const_fn)]
7879
#![feature(core_intrinsics)]
7980
#![feature(custom_attribute)]
81+
#![feature(drop_in_place)]
82+
#![feature(dropck_parametricity)]
8083
#![feature(fundamental)]
8184
#![feature(lang_items)]
85+
#![feature(needs_allocator)]
8286
#![feature(optin_builtin_traits)]
8387
#![feature(placement_in_syntax)]
84-
#![feature(placement_new_protocol)]
85-
#![feature(raw)]
8688
#![feature(shared)]
8789
#![feature(staged_api)]
8890
#![feature(unboxed_closures)]
8991
#![feature(unique)]
9092
#![feature(unsafe_no_drop_flag, filling_drop)]
91-
#![feature(dropck_parametricity)]
9293
#![feature(unsize)]
93-
#![feature(drop_in_place)]
94-
#![feature(fn_traits)]
95-
#![feature(const_fn)]
96-
97-
#![feature(needs_allocator)]
9894

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

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

105102
#[cfg(stage0)]

src/libcollections/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#![feature(unicode)]
5757
#![feature(unique)]
5858
#![feature(unsafe_no_drop_flag)]
59-
#![cfg_attr(test, feature(clone_from_slice, rand, test))]
59+
#![cfg_attr(test, feature(rand, test))]
6060

6161
#![no_std]
6262

src/libcollections/slice.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,14 @@
8383

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

8888
use alloc::boxed::Box;
89-
use core::clone::Clone;
9089
use core::cmp::Ordering::{self, Greater, Less};
91-
use core::cmp::{self, Ord, PartialEq};
92-
use core::iter::Iterator;
93-
use core::marker::Sized;
90+
use core::cmp;
9491
use core::mem::size_of;
9592
use core::mem;
96-
use core::ops::FnMut;
97-
use core::option::Option::{self, Some, None};
9893
use core::ptr;
99-
use core::result::Result;
10094
use core::slice as core_slice;
10195

10296
use borrow::{Borrow, BorrowMut, ToOwned};
@@ -136,12 +130,7 @@ pub use self::hack::to_vec;
136130
// `test_permutations` test
137131
mod hack {
138132
use alloc::boxed::Box;
139-
use core::clone::Clone;
140-
#[cfg(test)]
141-
use core::iter::Iterator;
142133
use core::mem;
143-
#[cfg(test)]
144-
use core::option::Option::{Some, None};
145134

146135
#[cfg(test)]
147136
use string::ToString;

src/libcollections/str.rs

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
// It's cleaner to just turn off the unused_imports warning than to fix them.
2020
#![allow(unused_imports)]
2121

22-
use core::clone::Clone;
23-
use core::iter::{Iterator, Extend};
24-
use core::option::Option::{self, Some, None};
25-
use core::result::Result;
2622
use core::str as core_str;
2723
use core::str::pattern::Pattern;
2824
use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};

src/libcollectionstest/slice.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
use std::cmp::Ordering::{Equal, Greater, Less};
12-
use std::default::Default;
1312
use std::mem;
1413
use std::__rand::{Rng, thread_rng};
1514
use std::rc::Rc;

src/librand/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#![feature(custom_attribute)]
3737
#![allow(unused_attributes)]
3838

39-
#![cfg_attr(test, feature(test, rand, rustc_private, iter_order_deprecated))]
39+
#![cfg_attr(test, feature(test, rand, rustc_private))]
4040

4141
#![allow(deprecated)]
4242

src/libserialize/json.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2606,7 +2606,6 @@ impl FromStr for Json {
26062606
mod tests {
26072607
extern crate test;
26082608
use self::Animal::*;
2609-
use self::DecodeEnum::*;
26102609
use self::test::Bencher;
26112610
use {Encodable, Decodable};
26122611
use super::Json::*;

src/libstd/dynamic_lib.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
reason = "API has not been scrutinized and is highly likely to \
1717
either disappear or change",
1818
issue = "27810")]
19-
#![rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")]
2019
#![allow(missing_docs)]
2120
#![allow(deprecated)]
2221

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

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

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

131139
#[test]
132140
#[cfg_attr(any(windows,
@@ -167,6 +175,8 @@ mod tests {
167175
target_os = "openbsd"))]
168176
#[allow(deprecated)]
169177
fn test_errors_do_not_crash() {
178+
use path::Path;
179+
170180
// Open /dev/null as a library to get an error, and make sure
171181
// that only causes an error, and not a crash.
172182
let path = Path::new("/dev/null");

src/libstd/io/buffered.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,8 @@ mod tests {
10951095

10961096
thread::spawn(|| {
10971097
let mut writer = BufWriter::new(PanicWriter);
1098-
writer.write(b"hello world");
1099-
writer.flush();
1098+
let _ = writer.write(b"hello world");
1099+
let _ = writer.flush();
11001100
}).join().err().unwrap();
11011101

11021102
assert_eq!(WRITES.load(Ordering::SeqCst), 1);

src/libstd/os/raw.rs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ pub enum c_void {
6868
}
6969

7070
#[cfg(test)]
71+
#[allow(unused_imports)]
7172
mod tests {
7273
use any::TypeId;
7374
use libc;

src/libstd/path.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -3326,11 +3326,13 @@ mod tests {
33263326
"{:?}.ends_with({:?}), expected {:?}, got {:?}", $path1, $path2,
33273327
$ends_with, ends_with);
33283328

3329-
let relative_from = path1.relative_from(path2).map(|p| p.to_str().unwrap());
3329+
let relative_from = path1.strip_prefix(path2)
3330+
.map(|p| p.to_str().unwrap())
3331+
.ok();
33303332
let exp: Option<&str> = $relative_from;
33313333
assert!(relative_from == exp,
3332-
"{:?}.relative_from({:?}), expected {:?}, got {:?}", $path1, $path2,
3333-
exp, relative_from);
3334+
"{:?}.strip_prefix({:?}), expected {:?}, got {:?}",
3335+
$path1, $path2, exp, relative_from);
33343336
});
33353337
);
33363338

0 commit comments

Comments
 (0)