Skip to content

Commit 75c5bc9

Browse files
committed
auto merge of #5179 : alexcrichton/rust/default-warn-unused-import, r=graydon
I've found that unused imports can often start cluttering a project after a long time, and it's very useful to keep them under control. I don't like how Go forces a compiler error by default and it can't be changed, but I certainly want to know about them so I think that a warn is a good default. Now that the `unused_imports` lint option is a bit smarter, I think it's possible to change the default level to warn. This commit also removes all unused imports throughout the compiler and libraries (500+). The only odd things that I ran into were that some `use` statements had to have `#[cfg(notest)]` or `#[cfg(test)]` based on where they were. The ones with `notest` were mostly in core for modules like `cmp` whereas `cfg(test)` was for tests that weren't part of a normal `mod test` module.
2 parents 71f0981 + cb4ab76 commit 75c5bc9

File tree

220 files changed

+161
-731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+161
-731
lines changed

src/compiletest/common.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
use core::prelude::*;
1212

13-
use cmp;
14-
1513
#[deriving_eq]
1614
pub enum mode {
1715
mode_compile_fail,

src/compiletest/compiletest.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub mod errors;
3232
use std::getopts;
3333
use std::test;
3434

35-
use core::{result, either};
3635
use core::result::{Ok, Err};
3736

3837
use common::config;

src/compiletest/errors.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
use core::prelude::*;
1212

13-
use common::config;
14-
1513
use core::io;
1614
use core::io::ReaderUtil;
1715
use core::str;

src/compiletest/procsrv.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ use core::prelude::*;
1313
use core::io::{ReaderUtil, WriterUtil};
1414
use core::io;
1515
use core::libc::{c_int, pid_t};
16-
use core::libc;
1716
use core::os;
18-
use core::pipes;
1917
use core::run::spawn_process;
2018
use core::run;
2119
use core::str;
2220
use core::task;
23-
use core::vec;
2421

2522
#[cfg(target_os = "win32")]
2623
fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {

src/compiletest/runtest.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010

1111
use core::prelude::*;
1212

13-
use common;
1413
use common::mode_run_pass;
1514
use common::mode_run_fail;
1615
use common::mode_compile_fail;
1716
use common::mode_pretty;
1817
use common::config;
1918
use errors;
20-
use header;
2119
use header::load_props;
2220
use header::TestProps;
2321
use procsrv;

src/compiletest/util.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010

1111
use core::prelude::*;
1212

13-
use common;
1413
use common::config;
1514

1615
use core::io;
1716
use core::os::getenv;
18-
use core::os;
1917

2018
pub fn make_new_path(path: ~str) -> ~str {
2119

src/libcore/bool.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
//! Boolean logic
1313
14-
use bool;
15-
use cmp;
16-
use cmp::Eq;
1714
use option::{None, Option, Some};
15+
#[cfg(notest)] use cmp;
1816

1917
/// Negation / inverse
2018
pub pure fn not(v: bool) -> bool { !v }
@@ -82,7 +80,7 @@ impl cmp::Eq for bool {
8280
#[test]
8381
pub fn test_bool_from_str() {
8482
do all_values |v| {
85-
assert Some(v) == from_str(bool::to_str(v))
83+
assert Some(v) == from_str(to_str(v))
8684
}
8785
}
8886

src/libcore/char.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
//! Utilities for manipulating the char type
1212
13-
use char;
14-
use cmp::Eq;
1513
use option::{None, Option, Some};
1614
use str;
1715
use u32;
1816
use uint;
1917
use unicode;
2018

19+
#[cfg(notest)] use cmp::Eq;
20+
2121
/*
2222
Lu Uppercase_Letter an uppercase letter
2323
Ll Lowercase_Letter a lowercase letter
@@ -305,8 +305,8 @@ fn test_to_digit() {
305305

306306
#[test]
307307
fn test_is_ascii() {
308-
assert str::all(~"banana", char::is_ascii);
309-
assert ! str::all(~"ประเทศไทย中华Việt Nam", char::is_ascii);
308+
assert str::all(~"banana", is_ascii);
309+
assert ! str::all(~"ประเทศไทย中华Việt Nam", is_ascii);
310310
}
311311

312312
#[test]

src/libcore/dvec.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Note that recursive use is not permitted.
2020
*/
2121

2222
use cast;
23-
use cast::reinterpret_cast;
2423
use prelude::*;
2524
use ptr::null;
2625
use vec;

src/libcore/either.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! A type that represents one of two alternatives
1212
1313
use cmp::Eq;
14-
use cmp;
1514
use kinds::Copy;
1615
use result::Result;
1716
use result;

src/libcore/flate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ Simple compression
1717
use libc;
1818
use libc::{c_void, size_t, c_int};
1919
use ptr;
20-
use rand;
2120
use vec;
2221

22+
#[cfg(test)] use rand;
23+
2324
extern mod rustrt {
2425
unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
2526
src_buf_len: size_t,

src/libcore/hash.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
use io;
2323
use io::{Writer, WriterUtil};
24-
use os;
2524
use to_bytes::IterBytes;
2625
use uint;
2726
use vec;

src/libcore/hashmap.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ pub mod linear {
1919
use iter::BaseIter;
2020
use hash::Hash;
2121
use iter;
22-
use kinds::Copy;
2322
use option::{None, Option, Some};
24-
use option;
2523
use rand;
26-
use to_bytes::IterBytes;
2724
use uint;
2825
use vec;
2926

src/libcore/io.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ Basic input/output
1616

1717
use result::Result;
1818

19-
use cmp::Eq;
2019
use dvec::DVec;
2120
use int;
2221
use libc;
2322
use libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t};
2423
use libc::consts::os::posix88::*;
25-
use libc::consts::os::extra::*;
26-
use option;
2724
use os;
2825
use prelude::*;
2926
use ptr;
@@ -719,7 +716,9 @@ pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
719716
-> Result<Writer, ~str> {
720717

721718
#[cfg(windows)]
722-
fn wb() -> c_int { (O_WRONLY | O_BINARY) as c_int }
719+
fn wb() -> c_int {
720+
(O_WRONLY | libc::consts::os::extra::O_BINARY) as c_int
721+
}
723722

724723
#[cfg(unix)]
725724
fn wb() -> c_int { O_WRONLY as c_int }

src/libcore/iter-trait/dlist.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// except according to those terms.
1010

1111
mod inst {
12-
use cast;
13-
use dlist;
1412
use dlist::DList;
1513
use managed;
1614
use option::{Option, Some};

src/libcore/libc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,6 @@ pub mod funcs {
10071007

10081008
pub mod c95 {
10091009
use libc::types::common::c95::{FILE, c_void, fpos_t};
1010-
use libc::types::common::posix88::dirent_t;
10111010
use libc::types::os::arch::c95::{c_char, c_double, c_int, c_long};
10121011
use libc::types::os::arch::c95::{c_uint, c_ulong, c_void, size_t};
10131012

src/libcore/logging.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010

1111
//! Logging
1212
13-
use cast::transmute;
14-
use io;
1513
use libc;
16-
use repr;
17-
use vec;
1814

1915
#[nolink]
2016
extern mod rustrt {
@@ -48,6 +44,11 @@ pub fn console_off() {
4844
#[cfg(notest)]
4945
#[lang="log_type"]
5046
pub fn log_type<T>(level: u32, object: &T) {
47+
use cast::transmute;
48+
use io;
49+
use repr;
50+
use vec;
51+
5152
let bytes = do io::with_bytes_writer |writer| {
5253
repr::write_repr(writer, object);
5354
};

src/libcore/managed.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010

1111
//! Operations on managed box types
1212
13-
use cast::transmute;
14-
use cmp::{Eq, Ord};
15-
use managed::raw::BoxRepr;
16-
use prelude::*;
1713
use ptr;
1814

15+
#[cfg(notest)] use cmp::{Eq, Ord};
1916

2017
pub mod raw {
2118

src/libcore/nil.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Functions for the unit type.
1414
1515
*/
1616

17+
#[cfg(notest)]
1718
use cmp::{Eq, Ord};
1819

1920
#[cfg(notest)]

src/libcore/num/f32.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@
1111
//! Operations and constants for `f32`
1212
1313
use cmath;
14-
use cmp;
1514
use libc::{c_float, c_int};
1615
use num::NumCast;
1716
use num::strconv;
1817
use num;
19-
use ops;
2018
use option::Option;
2119
use unstable::intrinsics::floorf32;
2220
use from_str;
2321
use to_str;
2422

23+
#[cfg(notest)] use cmp;
24+
#[cfg(notest)] use ops;
25+
2526
pub use cmath::c_float_targ_consts::*;
2627

2728
macro_rules! delegate(

src/libcore/num/f64.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
//! Operations and constants for `f64`
1212
1313
use cmath;
14-
use cmp;
1514
use libc::{c_double, c_int};
16-
use libc;
1715
use num::NumCast;
1816
use num::strconv;
1917
use num;
20-
use ops;
2118
use option::Option;
2219
use unstable::intrinsics::floorf64;
2320
use to_str;
2421
use from_str;
2522

23+
#[cfg(notest)] use cmp;
24+
#[cfg(notest)] use ops;
25+
2626
pub use cmath::c_double_targ_consts::*;
2727
pub use cmp::{min, max};
2828

src/libcore/num/float.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,17 @@
2020

2121
// PORT this must match in width according to architecture
2222

23-
use m_float = f64;
24-
25-
use cmp::{Eq, Ord};
26-
use cmp;
2723
use f64;
2824
use num::NumCast;
2925
use num::strconv;
3026
use num;
31-
use ops;
3227
use option::{None, Option, Some};
33-
use str;
34-
use uint;
3528
use to_str;
3629
use from_str;
3730

31+
#[cfg(notest)] use cmp::{Eq, Ord};
32+
#[cfg(notest)] use ops;
33+
3834
pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
3935
pub use f64::logarithm;
4036
pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};

src/libcore/num/int-template.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,15 @@
1010

1111
use T = self::inst::T;
1212

13-
use char;
14-
use cmp::{Eq, Ord};
15-
use cmp;
1613
use to_str::ToStr;
1714
use from_str::FromStr;
1815
use num::{ToStrRadix, FromStrRadix};
1916
use num::strconv;
2017
use num;
2118
use prelude::*;
22-
use str;
23-
use uint;
24-
use vec;
25-
use i8;
26-
use i16;
27-
use i32;
19+
20+
#[cfg(notest)] use cmp::{Eq, Ord};
21+
2822
pub use cmp::{min, max};
2923

3024
pub const bits : uint = inst::bits;

src/libcore/num/num.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
use cmp::{Ord, Eq};
1313
use ops::{Add, Div, Modulo, Mul, Neg, Sub};
1414
use option::{None, Option, Some};
15-
use char;
16-
use str;
1715
use kinds::Copy;
18-
use vec;
1916

2017
pub mod strconv;
2118

src/libcore/num/uint-template.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,15 @@
1111
use T = self::inst::T;
1212
use T_SIGNED = self::inst::T_SIGNED;
1313

14-
use char;
15-
use cmp::{Eq, Ord};
16-
use cmp;
1714
use to_str::ToStr;
1815
use from_str::FromStr;
1916
use num::{ToStrRadix, FromStrRadix};
2017
use num::strconv;
2118
use num;
2219
use option::{None, Option, Some};
2320
use prelude::*;
24-
use str;
25-
use uint;
26-
use vec;
27-
use u8;
28-
use u16;
29-
use u32;
21+
22+
#[cfg(notest)] use cmp::{Eq, Ord};
3023

3124
pub use cmp::{min, max};
3225

@@ -357,7 +350,6 @@ pub fn to_str_radix37() {
357350
uint::to_str_radix(100u, 37u);
358351
}
359352
360-
use io;
361353
#[test]
362354
pub fn test_ranges() {
363355
let mut l = ~[];

0 commit comments

Comments
 (0)