mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
7f84ede33d
Fix error message for `env!` when env var is not valid Unicode Currently (without this PR) the `env!` macro emits an ```environment variable `name` not defined at compile time``` error when the environment variable is defined, but not a valid Unicode string. This PR introduces a separate more accurate error message, and a test to verify this behaviour. For reference, before this PR, the new test would have outputted: ``` error: environment variable `NON_UNICODE_VAR` not defined at compile time --> non_unicode_env.rs:2:13 | 2 | let _ = env!("NON_UNICODE_VAR"); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `std::env::var("NON_UNICODE_VAR")` to read the variable at run time = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error ``` whereas with this PR, the test ouputs: ``` error: environment variable `NON_UNICODE_VAR` is not a valid Unicode string --> non_unicode_env.rs:2:13 | 2 | let _ = env!("NON_UNICODE_VAR"); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error ``` |
||
---|---|---|
.. | ||
assembly | ||
auxiliary | ||
codegen | ||
codegen-units | ||
coverage | ||
coverage-run-rustdoc | ||
debuginfo | ||
incremental | ||
mir-opt | ||
pretty | ||
run-make | ||
run-make-fulldeps | ||
run-pass-valgrind | ||
rustdoc | ||
rustdoc-gui | ||
rustdoc-js | ||
rustdoc-js-std | ||
rustdoc-json | ||
rustdoc-ui | ||
ui | ||
ui-fulldeps | ||
COMPILER_TESTS.md |