rust-lang / rust-lang/rust-clippy

Deny imports from (configurable) modules

Open
#14,807 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

If you have two modules containing equally or almost equally named types, you sometimes want to make sure that you never import any of these types, but always specify them by their path.

To ensure that, this lint denies importing from configured modules, and suggests to import the module instead.

Advantage

No more ambiguity when having multiple types named equally that you might mix up accidentially.

Drawbacks

No response

Example
use crate::foo::Something;

// lots of code

fn process_bar_something(smth: Something) {
    // ... Use the Something which I would expect to be crate::bar::Something
}

Could be written as:

use crate::bar;

fn process_bar_something(smth: bar::Something) {
    // ... Use the Something which I would expect to be crate::bar::Something
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files, tests, or entry points are named in the issue. Start by locating existing Clippy lints for imports and configurable settings, then define the affected module patterns and suggestion behavior; done means configured imports are denied and importing the module is suggested, with coverage for the example cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.