Closed
Description
Hi,
This issue suggests a new lint: undeclared_feature
. I tried following the guidelines, but feel free to change the name obviously.
Take a fresh Cargo.toml
file and add time as an optional dependency. Now write this code:
#[cfg(feature=time)]
fn main() {
println!("foo");
}
#[cfg(not(feature=time))]
fn main() {
println!("bar");
}
You can then run:
$ cargo run
bar
and
$ cargo run --features time
foo
I believe this is bad practice because this code effectively has a "hidden" feature, which should probably be documented and exposed via the Cargo.toml file. What do you think? Is this good / bad practice, and would a clippy lint be appropriate?
Metadata
Metadata
Assignees
Labels
No labels