rust-lang / rust-lang/rust-clippy

Check usages of empty features

Open
#8,402 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What it does

Check for all "empty" features in Cargo.toml (a_feature = []), with no optional dependency name collisions, and try to find if any config attribute in the file has that feature, if it doesn't, raise.

Lint Name

unused_crate_feature

Category

pedantic

Advantage
  • Allow libraries to clean up unused features, which could then signal downstream that something has changed.
  • Cleaner code and crates, with less "cruft"
Drawbacks

Possible false-positives if cargo were to infer more from features in the future (other than optional dependencies and the likes)

Example
[features]
a_thing = []

This feature is nowhere to be found in any source code, so this raises the warning.

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 with the [features] section in Cargo.toml and the source code that handles crate features and config attributes. Check how optional dependency name collisions and feature references are represented before defining the lint. Done means unused_crate_feature reports empty features with no optional dependency collision when no source configuration attribute uses them.

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.