Hacker News new | ask | show | jobs
by SnowProblem 1037 days ago
I don't understand why this is so complex? Just make it a feature you put in Cargo.toml:

serde = { version = "1.0", features = ["serde_derive", "fast_compile"] }

Either opt-in or opt-out is fine. It's surely useful during development but it shouldn't be on for production builds. Any transitivity issues should be considered problems with the dependency.

1 comments

This doesn't fix the problem, since features don't apply transitively. The correct workaround is to use [patch].

There's also the problem that the build may fail because it will still download the binary, which you may want to forbid entirely.

Sure features are transitive. A crate’s features at build are the superset of what every package defines. If I define “fast_compile” (opt-in) or “no_binaries” (opt-out) it’ll get applied across the board, will it not?
It depends. Features are not unified with resolver = 2 for proc macros.

https://doc.rust-lang.org/cargo/reference/resolver.html#feat...

That said I'm not sure how that applies transitively, I could have sworn I've seen conflicting features not cause transitive build failures.