forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#108573 - kornelski:runtimeenvs, r=WaffleLapkin
Explain compile-time vs run-time difference in env!() error message This PR is clarifying error message of `env!()` based on this user question: https://users.rust-lang.org/t/environment-variable-out-dir-is-undefined/90067 It makes it clear that `env!()` is for env variables defined at compile-time. There's special-case help text for common Cargo build script variables. I've also rearranged the code to avoid allocating error message on the happy path when the env var is defined.
- Loading branch information
Showing
5 changed files
with
43 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
fn main() { | ||
env!("__HOPEFULLY_NOT_DEFINED__"); | ||
//~^ ERROR: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined | ||
env!("CARGO__HOPEFULLY_NOT_DEFINED__"); | ||
//~^ ERROR: environment variable `CARGO__HOPEFULLY_NOT_DEFINED__` not defined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters