Wildcard use …​::* import

ID

rust.maintainability.avoid_star_import

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Readability

Language

Rust

Description

Reports a glob import (use path::*;) that pulls every public item of a module into the current scope. Preludes, super::* and glob imports inside a mod tests block are not reported, since those are the idiomatic uses of the form.

Rationale

A glob import hides where a name comes from, so a reader has to search the whole dependency tree to resolve an identifier. It also makes the code fragile: adding a public item upstream can shadow a local name or introduce an ambiguity that breaks the build in a file that was never edited.

The following code illustrates the pattern detected by this rule:

// FLAGGED: Wildcard `use ...::*` import
use std::collections::*;

Remediation

List the items you actually use: use std::collections::{HashMap, HashSet};. When the list grows unwieldy, import the module instead and qualify at the use site (use std::collections; collections::HashMap::new()).

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved