forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(except in the case where traits are imported and their unusedness is determined in typeck)
- Loading branch information
1 parent
2079a08
commit 8f88a48
Showing
4 changed files
with
235 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// 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. | ||
|
||
#![deny(unused_imports)] | ||
|
||
fn f() {} | ||
fn g() {} | ||
fn h() {} | ||
|
||
mod basic { | ||
use super::f; //~ ERROR unused import | ||
} | ||
|
||
mod part_of_group { | ||
use super::{f, g, h}; //~ ERROR unused import | ||
fn main() { | ||
h(); | ||
} | ||
} | ||
|
||
mod part_of_group_leaving_one { | ||
use super::{f, g, h}; //~ ERROR unused import | ||
|
||
fn main() { | ||
g(); | ||
h(); | ||
} | ||
} | ||
|
||
mod whole_group { | ||
use super::{f, g, h}; //~ ERROR unused import | ||
} | ||
|
||
mod empty_groups { | ||
use super::{{}, basic::{}}; //~ ERROR unused import | ||
} | ||
|
||
mod nested_group_all_unused { | ||
use std::{collections::{binary_heap::{BinaryHeap}, HashMap, linked_list::*}, io::*}; | ||
//^ ERROR unused import | ||
} | ||
|
||
mod nested_group_leaving_one { | ||
use std::{collections::{binary_heap::{BinaryHeap}, HashMap, linked_list::*}, io::*}; | ||
//^ ERROR unused import | ||
|
||
fn main() { | ||
HashMap::<u32, u32>::default(); | ||
} | ||
} | ||
|
||
mod maintains_trailing_comma { | ||
use std::collections::{HashMap, HashSet, LinkedList,}; //~ ERROR unused import | ||
|
||
fn main() { | ||
HashMap::<u32, u32>::default(); | ||
LinkedList::<u32>::default(); | ||
} | ||
} | ||
|
||
mod maintains_unaffected_single_groups { | ||
// We shouldn't remove the {}s around prelude::*, | ||
// in case that's the user's preference ¯\_(ツ)_/¯ | ||
use std::{io::{prelude::*}, collections::{BinaryHeap, HashMap}}; //~ ERROR unused import | ||
|
||
fn main() { | ||
let x: HashMap<Box<Read>, Box<Write>> = unimplemented!(); | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
error: unused import: `super::f` | ||
--> $DIR/unused-imports.rs:20:9 | ||
| | ||
LL | use super::f; //~ ERROR unused import | ||
| ----^^^^^^^^- help: this import can be removed | ||
| | ||
note: lint level defined here | ||
--> $DIR/unused-imports.rs:11:9 | ||
| | ||
LL | #![deny(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: unused imports: `f`, `g` | ||
--> $DIR/unused-imports.rs:24:17 | ||
| | ||
LL | use super::{f, g, h}; //~ ERROR unused import | ||
| ------------^--^----- help: parts of this import can be removed: `use super::h` | ||
|
||
error: unused import: `f` | ||
--> $DIR/unused-imports.rs:31:17 | ||
| | ||
LL | use super::{f, g, h}; //~ ERROR unused import | ||
| ------------^-------- help: parts of this import can be removed: `use super::{g, h}` | ||
|
||
error: unused imports: `f`, `g`, `h` | ||
--> $DIR/unused-imports.rs:40:17 | ||
| | ||
LL | use super::{f, g, h}; //~ ERROR unused import | ||
| ------------^--^--^-- help: this import can be removed | ||
|
||
error: unused imports: `basic::{}`, `{}` | ||
--> $DIR/unused-imports.rs:44:17 | ||
| | ||
LL | use super::{{}, basic::{}}; //~ ERROR unused import | ||
| ------------^^--^^^^^^^^^-- help: this import can be removed | ||
|
||
error: unused imports: `BinaryHeap`, `HashMap`, `io::*`, `linked_list::*` | ||
--> $DIR/unused-imports.rs:48:43 | ||
| | ||
LL | use std::{collections::{binary_heap::{BinaryHeap}, HashMap, linked_list::*}, io::*}; //~ ERROR unused import | ||
| --------------------------------------^^^^^^^^^^---^^^^^^^--^^^^^^^^^^^^^^---^^^^^-- help: this import can be removed | ||
|
||
error: unused imports: `BinaryHeap`, `io::*`, `linked_list::*` | ||
--> $DIR/unused-imports.rs:52:43 | ||
| | ||
LL | use std::{collections::{binary_heap::{BinaryHeap}, HashMap, linked_list::*}, io::*}; //~ ERROR unused import | ||
| --------------------------------------^^^^^^^^^^------------^^^^^^^^^^^^^^---^^^^^-- help: parts of this import can be removed: `use std::collections::HashMap` | ||
|
||
error: unused import: `HashSet` | ||
--> $DIR/unused-imports.rs:60:37 | ||
| | ||
LL | use std::collections::{HashMap, HashSet, LinkedList,}; //~ ERROR unused import | ||
| --------------------------------^^^^^^^--------------- help: parts of this import can be removed: `use std::collections::{HashMap, LinkedList,}` | ||
|
||
error: unused import: `BinaryHeap` | ||
--> $DIR/unused-imports.rs:71:47 | ||
| | ||
LL | use std::{io::{prelude::*}, collections::{BinaryHeap, HashMap}}; //~ ERROR unused import | ||
| ------------------------------------------^^^^^^^^^^------------ help: parts of this import can be removed: `use std::{io::{prelude::*}, collections::HashMap}` | ||
|
||
error: aborting due to 9 previous errors | ||
|