rust-lang / rust-lang/rust-clippy

Unecessarily public item

Open
#11,784 0 comments 6 reactions 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

Lint items that are exported as pub, but are not used outside of the module they're defined in.

Advantage

Ensure code is not more public than it needs to be, enforcing abstraction boundaries

Drawbacks

High possibility of false positives. Should be in the pedantic category, and have some heuristics for ignoring items that are intended to be exported from the crate to other crates (eg don't lint on items exported from lib.rs or prelude.rs)

Example
mod foo {
    pub fn f() {}

    pub fn g() { 
        f()
    }
}

Could be written as:

mod foo {
    fn f() {}

    pub fn g() { 
        f()
    }
}

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

Start by reviewing the issue's Rust examples and the proposed exceptions for lib.rs and prelude.rs. Determine how a pedantic lint would identify pub items used only within their defining module and how it would avoid likely false positives. Done means the lint enforces narrower visibility while handling the stated export heuristics.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.