Group unused import warnings per path list
Given a file
```rust
use std::collections::{BinaryHeap, BTreeMap, BTreeSet};
fn main() {}
```
Show a single warning, instead of three for each unused import:
```nocode
warning: unused imports, #[warn(unused_imports)] on by default
--> foo.rs:1:24
|
1 | use std::collections::{BinaryHeap, BTreeMap, BTreeSet};
| ^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^
```
Include support for lints pointing at `MultilineSpan`s, instead of just
`Span`s.
This commit is contained in:
parent
0491a23177
commit
a820d99eb2
7 changed files with 82 additions and 26 deletions
|
|
@ -17,8 +17,9 @@ use std::mem::*; // shouldn't get errors for not using
|
|||
// everything imported
|
||||
|
||||
// Should get errors for both 'Some' and 'None'
|
||||
use std::option::Option::{Some, None}; //~ ERROR unused import: `Some`
|
||||
//~^ ERROR unused import: `None`
|
||||
use std::option::Option::{Some, None};
|
||||
//~^ ERROR unused imports: `None`, `Some`
|
||||
//~| ERROR unused imports: `None`, `Some`
|
||||
|
||||
use test::A; //~ ERROR unused import: `test::A`
|
||||
// Be sure that if we just bring some methods into scope that they're also
|
||||
|
|
|
|||
15
src/test/ui/span/multispan-import-lint.rs
Normal file
15
src/test/ui/span/multispan-import-lint.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// 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.
|
||||
|
||||
use std::cmp::{Eq, Ord, min, PartialEq, PartialOrd};
|
||||
|
||||
fn main() {
|
||||
let _ = min(1, 2);
|
||||
}
|
||||
6
src/test/ui/span/multispan-import-lint.stderr
Normal file
6
src/test/ui/span/multispan-import-lint.stderr
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
warning: unused imports: `Eq`, `Ord`, `PartialEq`, `PartialOrd`, #[warn(unused_imports)] on by default
|
||||
--> $DIR/multispan-import-lint.rs:11:16
|
||||
|
|
||||
11 | use std::cmp::{Eq, Ord, min, PartialEq, PartialOrd};
|
||||
| ^^ ^^^ ^^^^^^^^^ ^^^^^^^^^^
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue