Rust-clippy: Potential false positive for wildcard_imports

Created on 18 Aug 2020  路  2Comments  路  Source: rust-lang/rust-clippy

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 (7e6d6e5f5 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>


L-bug L-enhancement good-first-issue

Most helpful comment

Hi, and welcome to Clippy!

Yes, I think that makes sense 馃憤

All 2 comments

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?

Hi, and welcome to Clippy!

Yes, I think that makes sense 馃憤

Was this page helpful?
0 / 5 - 0 ratings