about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-30 07:35:40 -0700
committerbors <bors@rust-lang.org>2013-08-30 07:35:40 -0700
commitf9142536a6e500c4f0fa70c433ef8026757bb9f0 (patch)
treecb94ea8c754dd2a3725c2ecef5c4c3f3fe70373a
parent0ac3e023d86fa84ed38bca3d34003b494fd28acf (diff)
parent6409f6bcf1b26c2b4bf810af1e3b797d387361e8 (diff)
downloadrust-f9142536a6e500c4f0fa70c433ef8026757bb9f0.tar.gz
rust-f9142536a6e500c4f0fa70c433ef8026757bb9f0.zip
auto merge of #8869 : alexcrichton/rust/issue-8847-fix-unused, r=huonw
Closes #8847
-rw-r--r--src/librustc/middle/resolve.rs2
-rw-r--r--src/test/compile-fail/lint-unused-import-tricky-globs.rs84
2 files changed, 86 insertions, 0 deletions
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index 2989f104729..c5be424e284 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -2585,11 +2585,13 @@ impl Resolver {
                 debug!("(resolving glob import) ... for value target");
                 dest_import_resolution.value_target =
                     Some(Target(containing_module, name_bindings));
+                dest_import_resolution.value_id = id;
             }
             if name_bindings.defined_in_public_namespace(TypeNS) {
                 debug!("(resolving glob import) ... for type target");
                 dest_import_resolution.type_target =
                     Some(Target(containing_module, name_bindings));
+                dest_import_resolution.type_id = id;
             }
         };
 
diff --git a/src/test/compile-fail/lint-unused-import-tricky-globs.rs b/src/test/compile-fail/lint-unused-import-tricky-globs.rs
new file mode 100644
index 00000000000..918b11b3253
--- /dev/null
+++ b/src/test/compile-fail/lint-unused-import-tricky-globs.rs
@@ -0,0 +1,84 @@
+// Copyright 2013 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_imports)];
+
+mod A {
+    pub fn p() {}
+}
+mod B {
+    pub fn p() {}
+}
+
+mod C {
+    pub fn q() {}
+}
+mod D {
+    pub fn q() {}
+}
+
+mod E {
+    pub fn r() {}
+}
+mod F {
+    pub fn r() {}
+}
+
+mod G {
+    pub fn s() {}
+    pub fn t() {}
+}
+mod H {
+    pub fn s() {}
+}
+
+mod I {
+    pub fn u() {}
+    pub fn v() {}
+}
+mod J {
+    pub fn u() {}
+    pub fn v() {}
+}
+
+mod K {
+    pub fn w() {}
+}
+mod L {
+    pub fn w() {}
+}
+
+mod m {
+   use A::p; //~ ERROR: unused import
+   use B::p;
+   use C::q; //~ ERROR: unused import
+   use D::*;
+   use E::*; //~ ERROR: unused import
+   use F::r;
+   use G::*;
+   use H::*;
+   use I::*;
+   use J::v;
+   use K::*; //~ ERROR: unused import
+   use L::*;
+
+   #[main]
+   fn my_main() {
+       p();
+       q();
+       r();
+       s();
+       t();
+       u();
+       v();
+       w();
+   }
+}
+