rust-lang / rust-lang/rust-clippy

[feat] report unused feature

Open
#14,178 1 comment 0 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

When dev, may enable some features.

// lib.rs
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
// hello.rs
code
code using generic_const_exprs
code

Then later, the related code using feature are removed.

// hello.rs
code
code

But maybe forget to remove these header.

// lib.rs
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
Advantage
  • clean lib.rs

  • per delete line, per SLOW build

Drawbacks

There seems many features, not sure if clippy can get info from rustc about unused feature.

Example

For scenario, related code are remove.

// hello.rs
code
code

Rerport all unused #![feature(XXX)]

// lib.rs
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

And maybe also report not need to enable features, feature need to enable before prev rust version but no need within new rust.

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 examples in lib.rs and hello.rs, then investigate whether rustc exposes enough information for Clippy to identify unused or no-longer-needed #![feature(...)] declarations. Done would be a defined, supportable report for the requested unused-feature scenario, with its scope and limitations documented.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.