rust/compiler
bors 7f84ede33d Auto merge of #122663 - beetrees:non-unicode-env-error, r=TaKO8Ki
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
```
2024-04-01 05:18:51 +00:00
..
rustc
rustc_abi Use the Align type when parsing alignment attributes 2024-04-01 03:05:55 +01:00
rustc_arena
rustc_ast Implement mut ref/mut ref mut 2024-03-27 09:53:23 -04:00
rustc_ast_ir Fix typo in VisitorResult 2024-03-08 23:20:29 -05:00
rustc_ast_lowering Implement mut ref/mut ref mut 2024-03-27 09:53:23 -04:00
rustc_ast_passes Rollup merge of #123188 - klensy:clippy-me2, r=Nilstrieb 2024-03-29 15:17:11 +01:00
rustc_ast_pretty Auto merge of #123080 - Jules-Bertholet:mut-ref-mut, r=Nadrieril 2024-03-29 11:08:11 +00:00
rustc_attr Use the Align type when parsing alignment attributes 2024-04-01 03:05:55 +01:00
rustc_baked_icu_data
rustc_borrowck Stop calling visitors V 2024-03-30 11:13:33 -04:00
rustc_builtin_macros Fix error message for env! when env var is not valid Unicode 2024-04-01 05:44:45 +01:00
rustc_codegen_cranelift Auto merge of #122450 - Urgau:simplify-trim-paths-feature, r=michaelwoerister 2024-03-29 14:00:21 +00:00
rustc_codegen_gcc stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gate 2024-03-29 19:59:46 -04:00
rustc_codegen_llvm Auto merge of #122972 - beetrees:use-align-type, r=fee1-dead 2024-04-01 03:16:45 +00:00
rustc_codegen_ssa Rollup merge of #123188 - klensy:clippy-me2, r=Nilstrieb 2024-03-29 15:17:11 +01:00
rustc_const_eval Rollup merge of #123133 - xiaoxiangxianzi:master, r=fmease 2024-03-27 23:27:24 +01:00
rustc_data_structures Auto merge of #121851 - michaelwoerister:mcp-533-effective-vis, r=cjgillot 2024-03-31 16:22:38 +00:00
rustc_driver
rustc_driver_impl Auto merge of #111769 - saethlin:ctfe-backtrace-ctrlc, r=RalfJung 2024-03-26 00:04:03 +00:00
rustc_error_codes Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk 2024-03-19 00:04:09 +00:00
rustc_error_messages Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_errors Rollup merge of #122737 - ytmimi:conditionally_ignore_fatal_diagnostic, r=davidtwco 2024-03-24 17:08:15 +01:00
rustc_expand compiler: fix few needless_pass_by_ref_mut clippy lints 2024-03-28 11:37:52 +03:00
rustc_feature Auto merge of #123080 - Jules-Bertholet:mut-ref-mut, r=Nadrieril 2024-03-29 11:08:11 +00:00
rustc_fluent_macro Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_fs_util
rustc_graphviz
rustc_hir Auto merge of #123080 - Jules-Bertholet:mut-ref-mut, r=Nadrieril 2024-03-29 11:08:11 +00:00
rustc_hir_analysis Auto merge of #122972 - beetrees:use-align-type, r=fee1-dead 2024-04-01 03:16:45 +00:00
rustc_hir_pretty Implement mut ref/mut ref mut 2024-03-27 09:53:23 -04:00
rustc_hir_typeck Stop calling visitors V 2024-03-30 11:13:33 -04:00
rustc_incremental Auto merge of #122721 - oli-obk:merge_queries, r=davidtwco 2024-03-25 01:33:46 +00:00
rustc_index doc: Add better explanation 2024-03-06 16:54:42 +01:00
rustc_index_macros Remove SpecOptionPartialEq 2024-03-19 16:32:01 +00:00
rustc_infer Rollup merge of #123188 - klensy:clippy-me2, r=Nilstrieb 2024-03-29 15:17:11 +01:00
rustc_interface Auto merge of #115220 - Zoxc:revive-gcx-ptr, r=oli-obk 2024-03-28 14:00:08 +00:00
rustc_lexer Silence redundant error on char literal that was meant to be a string in 2021 edition 2024-03-17 23:35:19 +00:00
rustc_lint Add support for NonNull in ambiguous_wide_ptr_comparisions 2024-03-29 22:02:07 +01:00
rustc_lint_defs Rollup merge of #121720 - tmandry:split-refining, r=compiler-errors 2024-03-16 23:28:47 +01:00
rustc_llvm RustWrapper: update call for llvm/llvm-project@44d037cc25 2024-03-26 14:10:25 -04:00
rustc_log bump tracing-tree to 0.3 2024-03-30 17:39:43 +03:00
rustc_macros Rename diagnostic derive things. 2024-03-11 10:06:34 +11:00
rustc_metadata Replace RemapFileNameExt::for_codegen with explicit calls 2024-03-28 18:47:26 +01:00
rustc_middle Auto merge of #122972 - beetrees:use-align-type, r=fee1-dead 2024-04-01 03:16:45 +00:00
rustc_mir_build Sort Eq candidates in the failure case too 2024-03-30 17:37:15 +01:00
rustc_mir_dataflow refactor check_{lang,library}_ub: use a single intrinsic, put policy into library 2024-03-23 18:45:05 +01:00
rustc_mir_transform Auto merge of #123194 - matthiaskrgr:rollup-vhdc8hw, r=matthiaskrgr 2024-03-29 16:02:04 +00:00
rustc_monomorphize Auto merge of #122671 - Mark-Simulacrum:const-panic-msg, r=Nilstrieb 2024-03-29 00:24:01 +00:00
rustc_next_trait_solver Require foldability part of interner item bounds, remove redundant where clauses 2024-03-28 12:30:52 -04:00
rustc_parse Auto merge of #123080 - Jules-Bertholet:mut-ref-mut, r=Nadrieril 2024-03-29 11:08:11 +00:00
rustc_parse_format Extend format arg help for simple tuple index access expression 2024-03-16 22:33:02 +00:00
rustc_passes Auto merge of #122450 - Urgau:simplify-trim-paths-feature, r=michaelwoerister 2024-03-29 14:00:21 +00:00
rustc_pattern_analysis Rollup merge of #123242 - Nadrieril:require-contiguous-enum-indices, r=compiler-errors 2024-03-31 11:50:41 +02:00
rustc_privacy Rename hir::Local into hir::LetStmt 2024-03-22 20:36:21 +01:00
rustc_query_impl Verify that query keys result in unique dep nodes 2024-03-12 05:31:41 +01:00
rustc_query_system Remove CacheSelector trait now that we can use GATs 2024-03-26 11:03:23 +00:00
rustc_resolve remove def_id_to_node_id in ast lowering 2024-03-28 16:58:03 +08:00
rustc_serialize Stabilize associated type bounds 2024-03-08 20:56:25 +00:00
rustc_session Rollup merge of #123200 - maurer:kcfi-abort, r=compiler-errors 2024-03-30 14:30:50 +01:00
rustc_smir Normalize the result of Fields::ty_with_args 2024-03-28 13:22:10 -07:00
rustc_span Auto merge of #121268 - Urgau:improve_ambi_wide_ptr_cmps, r=Nadrieril 2024-03-29 18:23:57 +00:00
rustc_symbol_mangling CFI: Rewrite closure and coroutine instances to their trait method 2024-03-30 16:40:38 +00:00
rustc_target CFI: Enable KCFI testing of run-pass tests 2024-03-26 03:16:41 +00:00
rustc_trait_selection Stop calling visitors V 2024-03-30 11:13:33 -04:00
rustc_traits Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
rustc_transmute Remove unnecessary Partial/Ord derive 2024-03-27 14:02:15 +00:00
rustc_ty_utils Rollup merge of #123021 - compiler-errors:coroutine-layout-lol, r=oli-obk 2024-03-27 10:13:43 +01:00
rustc_type_ir Require foldability part of interner item bounds, remove redundant where clauses 2024-03-28 12:30:52 -04:00
stable_mir Normalize the result of Fields::ty_with_args 2024-03-28 13:22:10 -07:00