-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
barand
$ 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?
facorread
Metadata
Metadata
Assignees
Labels
No labels