Skip to content

Export CARGO_PKG_EDITION variable to build environment #14872

Closed as not planned
@nyurik

Description

Problem

Some tools like bindgen may need to know the Rust language edition of the root crate, especially when executing as part of build.rs. For example, bindgen needs to know if the -sys package uses edition 2021 (so it can use C-string literals), or older (in which case it must generate some unsafe code with the same literals). Requiring the user to always pass in bindgen args that match their environment is less than ideal if the default could be computed on the fly using environment variables.

See rust-lang/rust-bindgen#3000

Proposed Solution

Publish CARGO_PKG_EDITION or CARGO_PKG_RUST_EDITION or CARGO_PKG_LANG_EDITION or ... (naming tbd)

Notes

No response

Metadata

Assignees

No one assigned

    Labels

    A-editionsArea: edition-specific issuesC-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