Skip to content
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

Document that cargo automatically registers variables used in env! macro to trigger rebuilds #15062

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

Imberflur
Copy link
Contributor

Initially discussed in https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/env!.2Foption_env!.20are.20tracked.2C.20can.20documentation.20be.20improved.3F/near/491793318

What does this PR try to resolve?

There is no documentation that I can find which indicates that cargo will rebuild for changes in the variables used in env! macros.

Because this was not always the case, when searching for information on this, the main result indicates otherwise https://users.rust-lang.org/t/should-env-cause-rebuild-is-env-var-changes/18013.

Users misled by this may turn to rerun-if-changed-env in a build script to trigger rebuilds, so this documentation is a useful place to catch users and indicate that it isn't needed for env! macros.

How should we test and review this PR?

I'm not sure how to test the new relative link but I matched it to the existing [env-macro]: ../../std/macro.env.html.

My main concern when writing this was whether it was clear that this applies to env! macro usage within the main code of the crate and not just in build.rs.

@rustbot
Copy link
Collaborator

rustbot commented Jan 14, 2025

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @epage (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 14, 2025
@weihanglo
Copy link
Member

Probably flaky. Return tests.

---- test::panic_abort_tests stdout ----
running `/home/runner/work/cargo/cargo/target/debug/cargo test -Z panic-abort-tests -v`

thread 'test::panic_abort_tests' panicked at tests/testsuite/test.rs:5023:10:

---- expected: tests/testsuite/test.rs:5014:13
++++ actual:   stderr
   1    1 | [RUNNING] `[..]--crate-name a [..]-C panic=abort[..]`
   2    2 | [RUNNING] `[..]--crate-name foo [..]-C panic=abort[..]`
   3      - [RUNNING] `[..]--crate-name foo [..]-C panic=abort[..]--test[..]`
   4    3 | ...∅

@weihanglo weihanglo enabled auto-merge January 15, 2025 00:37
@weihanglo weihanglo added the A-build-scripts Area: build.rs scripts label Jan 15, 2025
auto-merge was automatically disabled January 15, 2025 01:34

Head branch was pushed to by a user without write access

@Imberflur
Copy link
Contributor Author

I forgot to check here first and pushed to try to rerun the tests.

@weihanglo
Copy link
Member

I forgot to check here first and pushed to try to rerun the tests.

Nah. I added the comment just for a record, since I clicked the rerun button in GitHub CI dashboard.

@weihanglo weihanglo enabled auto-merge January 15, 2025 01:46
@weihanglo weihanglo added this pull request to the merge queue Jan 15, 2025
Merged via the queue into rust-lang:master with commit 1b77ac6 Jan 15, 2025
21 checks passed
@Imberflur Imberflur deleted the patch-1 branch January 15, 2025 03:45
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 18, 2025
Update cargo

13 commits in 088d496082726091024f1689c124a0c3dccbd775..045bf21b36a2e1f3ed85e38278d1c3cc4305e134
2025-01-10 20:10:21 +0000 to 2025-01-17 14:59:36 +0000
- created a function for user defined aliases (rust-lang/cargo#15076)
- took the functionality of the third party subcommand from the list_commands function (rust-lang/cargo#15075)
- fix: wrong concat and field name (rust-lang/cargo#15074)
- fix(publish): Report all unpublishable packages  (rust-lang/cargo#15070)
- docs(cargo-clippy): correct typo (rust-lang/cargo#15072)
- docs(cargo-package): alwasy include the lockfile (rust-lang/cargo#15067)
- docs(ref): Deprecate 'package.authors'  (rust-lang/cargo#15068)
- fix(build-std): parse as comma-separated list (rust-lang/cargo#15065)
- Fix benchsuite issue with newer versions of git (rust-lang/cargo#15069)
- Document that cargo automatically registers variables used in env! macro to trigger rebuilds (rust-lang/cargo#15062)
- perf(cargo-package): match certain path prefix with pathspec (rust-lang/cargo#14997)
- Clarify note in example (rust-lang/cargo#15054)
- chore(deps): update msrv (3 versions) to v1.82 (rust-lang/cargo#15050)
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 18, 2025
Update cargo

13 commits in 088d496082726091024f1689c124a0c3dccbd775..045bf21b36a2e1f3ed85e38278d1c3cc4305e134
2025-01-10 20:10:21 +0000 to 2025-01-17 14:59:36 +0000
- created a function for user defined aliases (rust-lang/cargo#15076)
- took the functionality of the third party subcommand from the list_commands function (rust-lang/cargo#15075)
- fix: wrong concat and field name (rust-lang/cargo#15074)
- fix(publish): Report all unpublishable packages  (rust-lang/cargo#15070)
- docs(cargo-clippy): correct typo (rust-lang/cargo#15072)
- docs(cargo-package): alwasy include the lockfile (rust-lang/cargo#15067)
- docs(ref): Deprecate 'package.authors'  (rust-lang/cargo#15068)
- fix(build-std): parse as comma-separated list (rust-lang/cargo#15065)
- Fix benchsuite issue with newer versions of git (rust-lang/cargo#15069)
- Document that cargo automatically registers variables used in env! macro to trigger rebuilds (rust-lang/cargo#15062)
- perf(cargo-package): match certain path prefix with pathspec (rust-lang/cargo#14997)
- Clarify note in example (rust-lang/cargo#15054)
- chore(deps): update msrv (3 versions) to v1.82 (rust-lang/cargo#15050)
@rustbot rustbot added this to the 1.86.0 milestone Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants