about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-01-22 03:42:24 +0000
committerbors <bors@rust-lang.org>2017-01-22 03:42:24 +0000
commite5b0829bb06969b69a82527253a393e5c500c324 (patch)
tree5d1239898227ea3f7832280c7a6a7a3f8261af67 /src/test
parent1b063750343601167f3d061a913172db2a0c2708 (diff)
parent191abc42642c29f589a34e7f6cdebd081c373138 (diff)
downloadrust-e5b0829bb06969b69a82527253a393e5c500c324.tar.gz
rust-e5b0829bb06969b69a82527253a393e5c500c324.zip
Auto merge of #39060 - jseyfried:improve_unused, r=nrc
Improve unused `extern crate` and unused `#[macro_use]` warnings

This PR
 - adds `unused_imports` warnings for unused `#[macro_use] extern crate` macro imports,
 - improves `unused_extern_crates` warnings (avoids false negatives), and
 - removes unused `#[macro_use]` imports and unused `extern crate`s.

r? @nrc
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/imports/unused-macro-use.rs21
-rw-r--r--src/test/compile-fail/lint-unused-extern-crate.rs7
2 files changed, 26 insertions, 2 deletions
diff --git a/src/test/compile-fail/imports/unused-macro-use.rs b/src/test/compile-fail/imports/unused-macro-use.rs
new file mode 100644
index 00000000000..365521970cd
--- /dev/null
+++ b/src/test/compile-fail/imports/unused-macro-use.rs
@@ -0,0 +1,21 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![deny(unused)]
+
+#[macro_use] //~ ERROR unused `#[macro_use]` import
+extern crate core;
+
+#[macro_use(
+    panic //~ ERROR unused `#[macro_use]` import
+)]
+extern crate core as core_2;
+
+fn main() {}
diff --git a/src/test/compile-fail/lint-unused-extern-crate.rs b/src/test/compile-fail/lint-unused-extern-crate.rs
index 52cb84f662d..40671353f8a 100644
--- a/src/test/compile-fail/lint-unused-extern-crate.rs
+++ b/src/test/compile-fail/lint-unused-extern-crate.rs
@@ -26,13 +26,16 @@ extern crate rand; // no error, the use marks it as used
 
 extern crate lint_unused_extern_crate as other; // no error, the use * marks it as used
 
-#[macro_use] extern crate core; // no error, the `#[macro_use]` marks it as used
-
 #[allow(unused_imports)]
 use rand::isaac::IsaacRng;
 
 use other::*;
 
+mod foo {
+    // Test that this is unused even though an earler `extern crate rand` is used.
+    extern crate rand; //~ ERROR unused extern crate
+}
+
 fn main() {
     let x: collecs::vec::Vec<usize> = Vec::new();
     let y = foo();