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:
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?
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.tomlfile and add time as an optional dependency. Now write this code:You can then run:
and
$ cargo run --features time fooI 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?