Hi, The Cargo feature request ticket directs a Pre-RFC here in the first instance. Also a previous discussion "pre-rfc-crate-defined-cfg-attributes"1 suggests cfg related functionality might best be addressed in Cargo.
Add a constrained/defined subset of #[cfg(...)] functionality to Cargo, via [cfg.features] in Cargo.tom, that enables the same rust-lang features/behavior available via rustc --cfg. The rustc --cfg feature is quite prominent, so was a little surprising this language feature (?) is not available in any degree via Cargo:
Something like the following is elegant and expressive, and is available to you if you build using rustc but not if you use cargo build|run:
That's not an omission, but a deliberate design decision. Cargo intentionally doesn't expose the full power of arbitrary cfg attributes. I don't remember off the top of my head the exact arguments for why the system works the way it does (that's probably explained in some issue/pr/rfc), but the overall idea is that unrestricted cfgs would break composition of independent cargo packages.
I addressed that in the OP: "Something like the following is elegant and expressive". Yes things can be rewritten, I gave that workaround in the OP. In the example I tried to convey that, in the example, trace is a particular configuration of features.
In case it mitigates the objections @matklad aluded to I've amended the proposal to be [cfg.features], because it is not more general than that.
Otherwise, I'll leave this as is - stalled.
If others have similar needs they'll likely find this thread.