cargo metadata
: Allow providing cfg
s in addition to --filter-platform
#15576
Labels
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Command-metadata
S-triage
Status: This issue is waiting on initial triage.
Uh oh!
There was an error while loading. Please reload this page.
Problem
Note: Split off of (and blocks) this rust-analyzer issue: rust-lang/rust-analyzer#19846
cargo metadata
has a--filter-platform
flag to return the effective dependency tree for a given platform, evaluating conditional dependencies like[target.'cfg(windows)'.dependencies]
and culling dependencies that evaluate tofalse
.This target dependency syntax supports any
cfg
condition, though:However, there doesn't seem to be a way to provide additional
cfg
s forcargo metadata
's dependency evaluation outside of setting one of theRUSTFLAGS
environment variables.This means that these conditional dependencies will be filtered out (for example by rust-analyzer's call of
cargo metadata
, see the linked issue above) as soon as--filter-platform
is used.Proposed Solution
From my limited perspective it seems that
cargo metadata
is missing a parameter like--filter-cfg
that would allow specifying these additionalcfgs
, bringing them to parity with platform-definedcfg
s.The proposed solution would be to add
--filter-cfg
with effectively the same syntax asrustc
's--cfg
.Notes
If this seems reasonable (or another way that might be) I'd like to give implementing it a try. Any guidance here would be appreciated!
The text was updated successfully, but these errors were encountered: