Skip to content

Commit 508c21e

Browse files
committed
Auto merge of #31314 - alexcrichton:less-warnings, r=brson
Help cleans up our build a bit and stays in line with the rest of our crates denying warnings traditionally.
2 parents a4a249f + ac83242 commit 508c21e

File tree

11 files changed

+51
-33
lines changed

11 files changed

+51
-33
lines changed

src/libcollectionstest/btree/map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ fn test_clone() {
379379
}
380380

381381
#[test]
382+
#[allow(dead_code)]
382383
fn test_variance() {
383384
use std::collections::btree_map::{Iter, IntoIter, Range, Keys, Values};
384385

src/libcollectionstest/btree/set.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ fn test_recovery() {
256256
}
257257

258258
#[test]
259+
#[allow(dead_code)]
259260
fn test_variance() {
260261
use std::collections::btree_set::{IntoIter, Iter, Range};
261262

src/libcollectionstest/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(warnings)]
12+
1113
#![feature(ascii)]
1214
#![feature(binary_heap_extras)]
1315
#![feature(box_syntax)]
@@ -16,27 +18,20 @@
1618
#![feature(collections_bound)]
1719
#![feature(const_fn)]
1820
#![feature(fn_traits)]
19-
#![feature(deque_extras)]
20-
#![feature(drain)]
2121
#![feature(enumset)]
22-
#![feature(into_cow)]
2322
#![feature(iter_arith)]
2423
#![feature(pattern)]
2524
#![feature(rand)]
26-
#![feature(range_inclusive)]
2725
#![feature(rustc_private)]
2826
#![feature(set_recovery)]
2927
#![feature(slice_bytes)]
30-
#![feature(slice_splits)]
3128
#![feature(step_by)]
3229
#![feature(str_char)]
3330
#![feature(str_escape)]
34-
#![feature(str_match_indices)]
3531
#![feature(str_utf16)]
3632
#![feature(test)]
3733
#![feature(unboxed_closures)]
3834
#![feature(unicode)]
39-
#![feature(vec_push_all)]
4035

4136
#[macro_use] extern crate log;
4237

src/libcollectionstest/slice.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ fn test_vec_default() {
866866
}
867867

868868
#[test]
869+
#[allow(deprecated)]
869870
fn test_bytes_set_memory() {
870871
use std::slice::bytes::MutableByteVector;
871872

src/libcollectionstest/string.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,27 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::borrow::{IntoCow, Cow};
11+
use std::borrow::Cow;
1212
use std::iter::repeat;
1313

1414
use test::Bencher;
1515

16+
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
17+
fn into_cow(self) -> Cow<'a, B>;
18+
}
19+
20+
impl<'a> IntoCow<'a, str> for String {
21+
fn into_cow(self) -> Cow<'a, str> {
22+
Cow::Owned(self)
23+
}
24+
}
25+
26+
impl<'a> IntoCow<'a, str> for &'a str {
27+
fn into_cow(self) -> Cow<'a, str> {
28+
Cow::Borrowed(self)
29+
}
30+
}
31+
1632
#[test]
1733
fn test_from_str() {
1834
let owned: Option<::std::string::String> = "string".parse().ok();
@@ -175,7 +191,7 @@ fn test_push_bytes() {
175191
let mut s = String::from("ABC");
176192
unsafe {
177193
let mv = s.as_mut_vec();
178-
mv.push_all(&[b'D']);
194+
mv.extend_from_slice(&[b'D']);
179195
}
180196
assert_eq!(s, "ABCD");
181197
}

src/libcollectionstest/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ fn do_bench_push_all(b: &mut Bencher, dst_len: usize, src_len: usize) {
686686

687687
b.iter(|| {
688688
let mut dst = dst.clone();
689-
dst.push_all(&src);
689+
dst.extend_from_slice(&src);
690690
assert_eq!(dst.len(), dst_len + src_len);
691691
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
692692
});

src/libcoretest/fmt/num.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
use core::fmt::radix;
1110

1211
#[test]
1312
fn test_format_int() {
@@ -153,17 +152,22 @@ fn test_format_int_twos_complement() {
153152
}
154153

155154
#[test]
155+
#[allow(deprecated)]
156156
fn test_format_radix() {
157+
use core::fmt::radix;
157158
assert!(format!("{:04}", radix(3, 2)) == "0011");
158159
assert!(format!("{}", radix(55, 36)) == "1j");
159160
}
160161

161162
#[test]
162163
#[should_panic]
164+
#[allow(deprecated)]
163165
fn test_radix_base_too_large() {
166+
use core::fmt::radix;
164167
let _ = radix(55, 37);
165168
}
166169

170+
#[allow(deprecated)]
167171
mod u32 {
168172
use test::Bencher;
169173
use core::fmt::radix;
@@ -207,6 +211,7 @@ mod u32 {
207211
}
208212
}
209213

214+
#[allow(deprecated)]
210215
mod i32 {
211216
use test::Bencher;
212217
use core::fmt::radix;

src/libcoretest/iter.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,15 @@ fn test_count() {
607607
}
608608

609609
#[test]
610-
fn test_max_by() {
610+
fn test_max_by_key() {
611611
let xs: &[isize] = &[-3, 0, 1, 5, -10];
612-
assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
612+
assert_eq!(*xs.iter().max_by_key(|x| x.abs()).unwrap(), -10);
613613
}
614614

615615
#[test]
616-
fn test_min_by() {
616+
fn test_min_by_key() {
617617
let xs: &[isize] = &[-3, 0, 1, 5, -10];
618-
assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0);
618+
assert_eq!(*xs.iter().min_by_key(|x| x.abs()).unwrap(), 0);
619619
}
620620

621621
#[test]
@@ -961,18 +961,18 @@ fn bench_multiple_take(b: &mut Bencher) {
961961
fn scatter(x: i32) -> i32 { (x * 31) % 127 }
962962

963963
#[bench]
964-
fn bench_max_by(b: &mut Bencher) {
964+
fn bench_max_by_key(b: &mut Bencher) {
965965
b.iter(|| {
966966
let it = 0..100;
967-
it.max_by(|&x| scatter(x))
967+
it.max_by_key(|&x| scatter(x))
968968
})
969969
}
970970

971971
// http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/
972972
#[bench]
973-
fn bench_max_by2(b: &mut Bencher) {
973+
fn bench_max_by_key2(b: &mut Bencher) {
974974
fn max_index_iter(array: &[i32]) -> usize {
975-
array.iter().enumerate().max_by(|&(_, item)| item).unwrap().0
975+
array.iter().enumerate().max_by_key(|&(_, item)| item).unwrap().0
976976
}
977977

978978
let mut data = vec![0i32; 1638];

src/libcoretest/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,36 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(warnings)]
12+
1113
#![feature(as_unsafe_cell)]
1214
#![feature(borrow_state)]
1315
#![feature(box_syntax)]
1416
#![feature(cell_extras)]
1517
#![feature(const_fn)]
16-
#![feature(core)]
1718
#![feature(core_float)]
1819
#![feature(core_private_bignum)]
1920
#![feature(core_private_diy_float)]
2021
#![feature(dec2flt)]
2122
#![feature(decode_utf16)]
2223
#![feature(fixed_size_array)]
2324
#![feature(float_extras)]
24-
#![feature(float_from_str_radix)]
2525
#![feature(flt2dec)]
2626
#![feature(fmt_radix)]
2727
#![feature(iter_arith)]
2828
#![feature(iter_arith)]
29-
#![feature(iter_cmp)]
30-
#![feature(iter_order)]
3129
#![feature(libc)]
3230
#![feature(nonzero)]
33-
#![feature(num_bits_bytes)]
3431
#![feature(peekable_is_empty)]
3532
#![feature(ptr_as_ref)]
3633
#![feature(rand)]
37-
#![feature(range_inclusive)]
3834
#![feature(raw)]
39-
#![feature(slice_bytes)]
4035
#![feature(slice_patterns)]
4136
#![feature(step_by)]
4237
#![feature(test)]
4338
#![feature(unboxed_closures)]
4439
#![feature(unicode)]
4540
#![feature(unique)]
46-
#![feature(clone_from_slice)]
4741

4842
extern crate core;
4943
extern crate test;

src/libcoretest/num/int_macros.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ mod tests {
1414
use core::$T_i::*;
1515
use core::isize;
1616
use core::ops::{Shl, Shr, Not, BitXor, BitAnd, BitOr};
17+
use core::mem;
18+
1719
use num;
1820

1921
#[test]
@@ -85,9 +87,10 @@ mod tests {
8587

8688
#[test]
8789
fn test_count_zeros() {
88-
assert!(A.count_zeros() == BITS as u32 - 3);
89-
assert!(B.count_zeros() == BITS as u32 - 2);
90-
assert!(C.count_zeros() == BITS as u32 - 5);
90+
let bits = mem::size_of::<$T>() * 8;
91+
assert!(A.count_zeros() == bits as u32 - 3);
92+
assert!(B.count_zeros() == bits as u32 - 2);
93+
assert!(C.count_zeros() == bits as u32 - 5);
9194
}
9295

9396
#[test]

src/libcoretest/num/uint_macros.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mod tests {
1515
use num;
1616
use core::ops::{BitOr, BitAnd, BitXor, Shl, Shr, Not};
1717
use std::str::FromStr;
18+
use std::mem;
1819

1920
#[test]
2021
fn test_overflows() {
@@ -54,9 +55,10 @@ mod tests {
5455

5556
#[test]
5657
fn test_count_zeros() {
57-
assert!(A.count_zeros() == BITS as u32 - 3);
58-
assert!(B.count_zeros() == BITS as u32 - 2);
59-
assert!(C.count_zeros() == BITS as u32 - 5);
58+
let bits = mem::size_of::<$T>() * 8;
59+
assert!(A.count_zeros() == bits as u32 - 3);
60+
assert!(B.count_zeros() == bits as u32 - 2);
61+
assert!(C.count_zeros() == bits as u32 - 5);
6062
}
6163

6264
#[test]

0 commit comments

Comments
 (0)