Why is this an issue?

Importing every public name from a module using a wildcard (use _::*) is a bad idea because:

Remember that imported names can change when you update your dependencies. A wildcard import that works today might be broken tomorrow.

Exceptions

No issue will be raised for modules that their name contains prelude . Many crates, including the standard library, provide modules named prelude that are specifically designed for wildcard import.

No issue will be raised in test modules. This is defined as any module with test in the name.

How to fix it

There are two ways to avoid a wildcard import:

Code examples

Noncompliant code example

use std::collections::*; // Noncompliant
fn main() {
    let mut map = HashMap::new();
    map.insert(1, 2);
}

Compliant solution

use std::collections::HashMap;
fn main() {
    let mut map = HashMap::new();
    map.insert(1, 2);
}

Or

use std::collections::HashMap as HM;
fn main() {
    let mut map = HM::new();
    map.insert(1, 2);
}

Resources

Documentation