File tree Expand file tree Collapse file tree 2 files changed +31
-11
lines changed Expand file tree Collapse file tree 2 files changed +31
-11
lines changed Original file line number Diff line number Diff line change @@ -213,15 +213,14 @@ impl Config {
213
213
} )
214
214
. collect ( ) ;
215
215
216
- let mut upper_case_env: HashMap < String , String > = HashMap :: new ( ) ;
217
-
218
- if !cfg ! ( windows) {
219
- upper_case_env = env
220
- . clone ( )
216
+ let upper_case_env = if cfg ! ( windows) {
217
+ HashMap :: new ( )
218
+ } else {
219
+ env. clone ( )
221
220
. into_iter ( )
222
221
. map ( |( k, _) | ( k. to_uppercase ( ) . replace ( "-" , "_" ) , k) )
223
- . collect ( ) ;
224
- }
222
+ . collect ( )
223
+ } ;
225
224
226
225
let cache_rustc_info = match env. get ( "CARGO_CACHE_RUSTC_INFO" ) {
227
226
Some ( cache) => cache != "0" ,
@@ -568,13 +567,16 @@ impl Config {
568
567
569
568
fn check_environment_key_case_mismatch ( & self , key : & ConfigKey ) {
570
569
if cfg ! ( windows) {
570
+ // In the case of windows the check for case mismatch in keys can be skipped
571
+ // as windows already converts its environment keys into the desired format.
571
572
return ;
572
573
}
574
+
573
575
match self . upper_case_env . get ( key. as_env_key ( ) ) {
574
576
Some ( env_key) => {
575
577
let _ = self . shell ( ) . warn ( format ! (
576
- "Variables in environment require uppercase,
577
- but given variable: {}, contains lowercase or dash ." ,
578
+ "Environment variables require uppercase letters, \
579
+ but the variable: `{}` contains lowercase letters or dashes .",
578
580
env_key
579
581
) ) ;
580
582
}
Original file line number Diff line number Diff line change @@ -368,14 +368,32 @@ fn target_in_environment_contains_lower_case() {
368
368
. env ( target_key, "nonexistent-linker" )
369
369
. with_status ( 101 )
370
370
. with_stderr_contains ( format ! (
371
- "warning: Variables in environment require uppercase,
372
- but given variable: {}, contains lowercase or dash ." ,
371
+ "warning: Environment variables require uppercase letters, \
372
+ but the variable: `{}` contains lowercase letters or dashes .",
373
373
target_key
374
374
) )
375
375
. run ( ) ;
376
376
}
377
377
}
378
378
379
+ #[ cargo_test]
380
+ #[ cfg( windows) ]
381
+ fn target_in_environment_contains_lower_case_on_windows ( ) {
382
+ let p = project ( ) . file ( "src/main.rs" , "fn main() {}" ) . build ( ) ;
383
+
384
+ let target_keys = [
385
+ "CARGO_TARGET_X86_64_UNKNOWN_LINUX_musl_LINKER" ,
386
+ "CARGO_TARGET_x86_64_unknown_linux_musl_LINKER" ,
387
+ ] ;
388
+
389
+ for target_key in & target_keys {
390
+ p. cargo ( "build -v --target x86_64-unknown-linux-musl" )
391
+ . env ( target_key, "nonexistent-linker" )
392
+ . without_status ( )
393
+ . run ( ) ;
394
+ }
395
+ }
396
+
379
397
#[ cargo_test]
380
398
fn cfg_ignored_fields ( ) {
381
399
// Test for some ignored fields in [target.'cfg()'] tables.
You can’t perform that action at this time.
0 commit comments