@@ -205,7 +205,7 @@ pub struct Config {
205
205
/// (relevant on Windows, where environment variables are case-insensitive).
206
206
case_insensitive_env : HashMap < OsString , OsString > ,
207
207
/// Environment variables converted to uppercase and with "-" replaced by "_"
208
- /// (the format expected by Cargo).
208
+ /// (the format expected by Cargo). This only contains entries that were valid UTF-8.
209
209
normalized_env : HashMap < String , String > ,
210
210
/// Tracks which sources have been updated to avoid multiple updates.
211
211
updated_sources : LazyCell < RefCell < HashSet < SourceId > > > ,
@@ -741,6 +741,15 @@ impl Config {
741
741
/// Helper primarily for testing.
742
742
pub fn set_env ( & mut self , env : HashMap < String , String > ) {
743
743
self . env = env. into_iter ( ) . map ( |( k, v) | ( k. into ( ) , v. into ( ) ) ) . collect ( ) ;
744
+ self . case_insensitive_env = self
745
+ . env
746
+ . keys ( )
747
+ . map ( |k| ( k. to_ascii_uppercase ( ) , k. to_owned ( ) ) )
748
+ . collect ( ) ;
749
+ self . normalized_env = self
750
+ . env ( )
751
+ . map ( |( k, _) | ( k. to_uppercase ( ) . replace ( "-" , "_" ) , k. to_owned ( ) ) )
752
+ . collect ( ) ;
744
753
}
745
754
746
755
/// Returns all environment variables as an iterator, filtering out entries
0 commit comments