rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.34k stars 1.53k forks source link

Check usages of empty features #8402

Open ShadowJonathan opened 2 years ago

ShadowJonathan commented 2 years ago

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

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.

ShadowJonathan commented 2 years ago

https://github.com/rust-lang/rust-clippy/issues/8301 and https://github.com/rust-lang/rust-clippy/issues/1614 are related to this lint