Skip to content

Introduce CARGO_PKG_EDITION env var #14873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Nov 29, 2024

Add CARGO_PKG_EDITION environment variable, allowing build scripts to determine the language edition of the crate being compiled.

Fixes #14872

TBD - EnvVar Name

  • CARGO_PKG_EDITION
  • CARGO_PKG_RUST_EDITION
  • CARGO_PKG_LANG_EDITION
  • CARGO_PKG_LANGUAGE_EDITION
  • ...?

@rustbot
Copy link
Collaborator

rustbot commented Nov 29, 2024

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 29, 2024
@nyurik nyurik force-pushed the pkg-lang-edition branch 3 times, most recently from a759287 to e7f96b4 Compare November 29, 2024 22:13
@epage
Copy link
Contributor

epage commented Nov 29, 2024

As a heads up, our contribution process asks that issues be accepted before moving on to PRs. There are two directions to go and this direction has non-obvious problems to work through. We should work through this first before looking at the implementation.

@bors
Copy link
Contributor

bors commented Dec 6, 2024

☔ The latest upstream changes (presumably 2560340) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot

This comment has been minimized.

@epage epage added the T-cargo Team: Cargo label Apr 11, 2025
Comment on lines +539 to +609
/// The Rust language edition from the manifest of your package.
#[track_caller]
pub fn cargo_pkg_edition() -> Option<String> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably list MSRV information

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at #14902, this should be

/// The Rust language edition from the manifest of your package.
#[doc = requires_msrv!("1.88")]
#[track_caller]
pub fn cargo_pkg_edition() -> String {

@@ -239,6 +239,7 @@ corresponding environment variable is set to the empty string, `""`.
* `CARGO_PKG_REPOSITORY` --- The repository from the manifest of your package.
* `CARGO_PKG_LICENSE` --- The license from the manifest of your package.
* `CARGO_PKG_LICENSE_FILE` --- The license file from the manifest of your package.
* `CARGO_PKG_EDITION` --- The Rust language edition from the manifest of your package.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also warn people about the deprecated behavior?

@nyurik nyurik force-pushed the pkg-lang-edition branch from e7f96b4 to 1548a7e Compare April 11, 2025 18:10
@rustbot rustbot added the A-build-scripts Area: build.rs scripts label Apr 11, 2025
@nyurik
Copy link
Contributor Author

nyurik commented Apr 11, 2025

@epage i rebased this PR. WRT your MSRV comments --- what kind of message do you think would be needed, and which version? Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-execution Area: anything dealing with executing the compiler A-build-scripts Area: build.rs scripts A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cargo Team: Cargo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export CARGO_PKG_EDITION variable to build environment
4 participants