}
if let ast::UseTreeKind::Nested(ref items) = use_tree.kind {
+ // If it's the parent group, cover the entire use item
+ let span = if nested {
+ use_tree.span
+ } else {
+ self.item_span
+ };
+
if items.len() == 0 {
self.unused_imports
.entry(self.base_id)
.or_insert_with(NodeMap)
- .insert(id, self.item_span);
+ .insert(id, span);
}
} else {
let base_id = self.base_id;
+++ /dev/null
-// Copyright 2017 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.
-
-#![feature(use_nested_groups)]
-#![deny(unused_imports)]
-
-mod foo {
- pub enum Bar {}
-}
-
-use foo::{*, *}; //~ ERROR unused import: `*`
-
-fn main() {
- let _: Bar;
-}
+++ /dev/null
-error: unused import: `*`
- --> $DIR/owl-import-generates-unused-import-lint.rs:18:14
- |
-18 | use foo::{*, *}; //~ ERROR unused import: `*`
- | ^
- |
-note: lint level defined here
- --> $DIR/owl-import-generates-unused-import-lint.rs:12:9
- |
-12 | #![deny(unused_imports)]
- | ^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
--- /dev/null
+// Copyright 2018 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.
+
+#![feature(use_nested_groups)]
+#![allow(dead_code)]
+#![deny(unused_imports)]
+
+mod foo {
+ pub mod bar {
+ pub mod baz {
+ pub struct Bar();
+ }
+ pub mod foobar {}
+ }
+
+ pub struct Foo();
+}
+
+use foo::{Foo, bar::{baz::{}, foobar::*}, *};
+ //~^ ERROR unused imports: `*`, `Foo`, `baz::{}`, `foobar::*`
+use foo::bar::baz::{*, *};
+ //~^ ERROR unused import: `*`
+use foo::{};
+ //~^ ERROR unused import: `use foo::{};`
+
+fn main() {
+ let _: Bar;
+}
--- /dev/null
+error: unused imports: `*`, `Foo`, `baz::{}`, `foobar::*`
+ --> $DIR/use-nested-groups-unused-imports.rs:26:11
+ |
+26 | use foo::{Foo, bar::{baz::{}, foobar::*}, *};
+ | ^^^ ^^^^^^^ ^^^^^^^^^ ^
+ |
+note: lint level defined here
+ --> $DIR/use-nested-groups-unused-imports.rs:13:9
+ |
+13 | #![deny(unused_imports)]
+ | ^^^^^^^^^^^^^^
+
+error: unused import: `*`
+ --> $DIR/use-nested-groups-unused-imports.rs:28:24
+ |
+28 | use foo::bar::baz::{*, *};
+ | ^
+
+error: unused import: `use foo::{};`
+ --> $DIR/use-nested-groups-unused-imports.rs:30:1
+ |
+30 | use foo::{};
+ | ^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+