diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2018-01-25 15:52:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-25 15:52:18 +0100 |
| commit | 58e56cca567921350f376cb3e2155029fc0df226 (patch) | |
| tree | 2b58b6c1d498c3963d6541640a4fb426a0415bce /src/test | |
| parent | 6f2a0c6f689797e9c2c876109b5acb4926c28634 (diff) | |
| parent | 0847ac026568b70f0927b85a1a2e3d2f79a6b48f (diff) | |
Rollup merge of #47726 - pietroalbini:fix-nested-empty-groups-span, r=petrochenkov
Fix spans in unused import lint for nested groups
This fixes an inconsistency for empty nested groups, and adds a test for all the possible cases of the lint.
```
warning: unused imports: `*`, `Foo`, `baz::{}`, `foobar::*`
--> test.rs:16:11
|
16 | use foo::{Foo, bar::{baz::{}, foobar::*}, *};
| ^^^ ^^^^^^^ ^^^^^^^^^ ^
|
= note: #[warn(unused_imports)] on by default
warning: unused import: `*`
--> test.rs:17:24
|
17 | use foo::bar::baz::{*, *};
| ^
warning: unused import: `use foo::{};`
--> test.rs:18:1
|
18 | use foo::{};
| ^^^^^^^^^^^^
```
cc #44494
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/owl-import-generates-unused-import-lint.stderr | 14 | ||||
| -rw-r--r-- | src/test/ui/use-nested-groups-unused-imports.rs (renamed from src/test/ui/owl-import-generates-unused-import-lint.rs) | 19 | ||||
| -rw-r--r-- | src/test/ui/use-nested-groups-unused-imports.stderr | 26 |
3 files changed, 42 insertions, 17 deletions
diff --git a/src/test/ui/owl-import-generates-unused-import-lint.stderr b/src/test/ui/owl-import-generates-unused-import-lint.stderr deleted file mode 100644 index 79089b2a93c..00000000000 --- a/src/test/ui/owl-import-generates-unused-import-lint.stderr +++ /dev/null @@ -1,14 +0,0 @@ -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 - diff --git a/src/test/ui/owl-import-generates-unused-import-lint.rs b/src/test/ui/use-nested-groups-unused-imports.rs index dc30c318352..ddbf54fdd48 100644 --- a/src/test/ui/owl-import-generates-unused-import-lint.rs +++ b/src/test/ui/use-nested-groups-unused-imports.rs @@ -1,4 +1,4 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -9,13 +9,26 @@ // except according to those terms. #![feature(use_nested_groups)] +#![allow(dead_code)] #![deny(unused_imports)] mod foo { - pub enum Bar {} + pub mod bar { + pub mod baz { + pub struct Bar(); + } + pub mod foobar {} + } + + pub struct Foo(); } -use foo::{*, *}; //~ ERROR unused import: `*` +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; diff --git a/src/test/ui/use-nested-groups-unused-imports.stderr b/src/test/ui/use-nested-groups-unused-imports.stderr new file mode 100644 index 00000000000..0686310dbf5 --- /dev/null +++ b/src/test/ui/use-nested-groups-unused-imports.stderr @@ -0,0 +1,26 @@ +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 + |
