Skip to content

Pass full feature list in environment variable #11769

Open
@rmccue

Description

@rmccue

Problem

Cargo passes over features one-by-one in CARGO_FEATURE_... environment variables:

// Be sure to pass along all enabled features for this package, this is the
// last piece of statically known information that we have.
for feat in &unit.features {
cmd.env(&format!("CARGO_FEATURE_{}", super::envify(feat)), "1");
}

However, there's no way to get a list of all of these variables, without iterating over every environment variable.

I'd like to be able to display the list of enabled features in the version information, and right now that requires testing each variable (via #[cfg(feature=)]).

Proposed Solution

A new environment variable ala CARGO_FEATURES with a comma-separated list of enabled features would allow grabbing this information easily. (Comma-separated would match the --features flag to cargo)

Notes

One potential downside of this is that it adds redundant information, and might make it a bit worse for users invoking the toolchain directly without using the cargo tool specifically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-environment-variablesArea: environment variablesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions