Skip to content

Warn when an import list is empty #38085

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Dec 7, 2016

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Nov 30, 2016

For a given file

use std::*;
use std::{};

output the following warnings

warning: unused import: `use std::{};`, #[warn(unused_imports)] on by default
 --> file.rs:2:1
  |
2 | use std::{};
  | ^^^^^^^^^^^^

warning: unused import: `std::*;`, #[warn(unused_imports)] on by default
 --> file.rs:1:5
  |
1 | use std::*;
  |     ^^^^^^^

@rust-highfive
Copy link
Contributor

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@estebank estebank force-pushed the empty-import-list-fix-38012 branch from beb8a4c to e8b5ede Compare November 30, 2016 08:18
@petrochenkov
Copy link
Contributor

This should be included into existing unused_imports lint, IMO.
Also, while being reasonable, this doesn't fix #38012, #38012 is about ::{} being accepted after non-modules.

@bors
Copy link
Collaborator

bors commented Nov 30, 2016

☔ The latest upstream changes (presumably #38014) made this pull request unmergeable. Please resolve the merge conflicts.

@eddyb
Copy link
Member

eddyb commented Nov 30, 2016

r? @jseyfried

@rust-highfive rust-highfive assigned jseyfried and unassigned eddyb Nov 30, 2016
@jseyfried
Copy link
Contributor

@estebank Could you make this an unused_imports lint as @petrochenkov suggested?

@estebank
Copy link
Contributor Author

estebank commented Dec 5, 2016

@jseyfried done!

@estebank estebank force-pushed the empty-import-list-fix-38012 branch 3 times, most recently from b0e17c8 to b4eca19 Compare December 5, 2016 22:24
For a given file

```rust
use std::*;
use std::{};
```

output the following warnings

```
warning: unused import: `use std::{};`, #[warn(unused_imports)] on by default
 --> file.rs:2:1
  |
2 | use std::{};
  | ^^^^^^^^^^^^

warning: unused import: `std::*;`, #[warn(unused_imports)] on by default
 --> file.rs:1:5
  |
1 | use std::*;
  |     ^^^^^^^
```
@estebank estebank force-pushed the empty-import-list-fix-38012 branch from b4eca19 to 58e70e7 Compare December 6, 2016 01:20
@jseyfried
Copy link
Contributor

@estebank Thanks!
@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Dec 6, 2016

📌 Commit 58e70e7 has been approved by jseyfried

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 7, 2016
…2, r=jseyfried

Warn when an import list is empty

For a given file

```rust
use std::*;
use std::{};
```

output the following warnings

```
warning: unused import: `use std::{};`, #[warn(unused_imports)] on by default
 --> file.rs:2:1
  |
2 | use std::{};
  | ^^^^^^^^^^^^

warning: unused import: `std::*;`, #[warn(unused_imports)] on by default
 --> file.rs:1:5
  |
1 | use std::*;
  |     ^^^^^^^
```
bors added a commit that referenced this pull request Dec 7, 2016
Rollup of 9 pull requests

- Successful merges: #38085, #38123, #38151, #38153, #38158, #38163, #38186, #38189, #38208
- Failed merges:
@bors bors merged commit 58e70e7 into rust-lang:master Dec 7, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants