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;

0 commit comments

Comments
 (0)