Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Potential false positive for wildcard_imports #5917

Closed
recmo opened this issue Aug 17, 2020 · 2 comments · Fixed by #5929
Closed

Potential false positive for wildcard_imports #5917

recmo opened this issue Aug 17, 2020 · 2 comments · Fixed by #5929
Labels
C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@recmo
Copy link

recmo commented Aug 17, 2020

I tried this code:

extern crate no_std_compat as std;

use std::prelude::v1::*;

I expected to see this happen: explanation

No warning, since this is a prelude import which is exempt from the wildcard_imports rule. I think it's the versioning suffix ::v1 from the no-std-compat crate that throws it off.

Instead, this happened: explanation

error: usage of wildcard import
 --> algebra/u256/src/multiplicative.rs:9:5
  |
9 |     prelude::v1::*,
  |     ^^^^^^^^^^^^^^ help: try: `prelude::v1::{Clone, Iterator}`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports

Meta

  • cargo clippy -V: clippy 0.0.212 (7e6d6e5 2020-08-16)
  • rustc -Vv:
    rustc 1.47.0-nightly (7e6d6e5f5 2020-08-16)
    binary: rustc
    commit-hash: 7e6d6e5f535321c2223f044caba16f97b825009c
    commit-date: 2020-08-16
    host: x86_64-apple-darwin
    release: 1.47.0-nightly
    LLVM version: 10.0
    
Backtrace

<backtrace>

@stchris
Copy link
Contributor

stchris commented Aug 20, 2020

Hi, I'd like to give this a go and try to submit a PR for this. As far as I can see https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/wildcard_imports.rs#L200 only allows wildcard where the last segment before the wildcard is "prelude", so I assume we would hereby allow wildcards where prelude comes up in any of the segments?

@ebroto
Copy link
Member

ebroto commented Aug 20, 2020

Hi, and welcome to Clippy!

Yes, I think that makes sense 👍

stchris added a commit to stchris/rust-clippy that referenced this issue Aug 20, 2020
Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form

```
use ...::prelude::*;
```

were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:

```
use ...::prelude::v1::*;
```

Fixes rust-lang#5917
stchris added a commit to stchris/rust-clippy that referenced this issue Aug 21, 2020
Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form

```
use ...::prelude::*;
```

were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:

```
use ...::prelude::v1::*;
```

Fixes rust-lang#5917
bors added a commit that referenced this issue Aug 22, 2020
Widen understanding of prelude import

Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form

```
use ...::prelude::*;
```

were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:

```
use ...::prelude::v1::*;
```

Fixes #5917

changelog: Allow `prelude` to appear in any segment of the import path in [`wildcard_imports`]
bors added a commit that referenced this issue Aug 22, 2020
Widen understanding of prelude import

Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form

```
use ...::prelude::*;
```

were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:

```
use ...::prelude::v1::*;
```

Fixes #5917

changelog: Allow `prelude` to appear in any segment of the import path in [`wildcard_imports`]
@bors bors closed this as completed in 5b07b9e Aug 22, 2020
hegza pushed a commit to hegza/rust-clippy that referenced this issue Aug 25, 2020
Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form

```
use ...::prelude::*;
```

were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:

```
use ...::prelude::v1::*;
```

Fixes rust-lang#5917
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants