@@ -441,7 +441,7 @@ impl TestProps {
441441 ln,
442442 UNSET_EXEC_ENV ,
443443 & mut self . unset_exec_env ,
444- |r| r,
444+ |r| r. trim ( ) . to_owned ( ) ,
445445 ) ;
446446 config. push_name_value_directive (
447447 ln,
@@ -453,7 +453,7 @@ impl TestProps {
453453 ln,
454454 UNSET_RUSTC_ENV ,
455455 & mut self . unset_rustc_env ,
456- |r| r,
456+ |r| r. trim ( ) . to_owned ( ) ,
457457 ) ;
458458 config. push_name_value_directive (
459459 ln,
@@ -979,16 +979,13 @@ impl Config {
979979
980980 fn parse_env ( nv : String ) -> ( String , String ) {
981981 // nv is either FOO or FOO=BAR
982- let mut strs: Vec < String > = nv. splitn ( 2 , '=' ) . map ( str:: to_owned) . collect ( ) ;
983-
984- match strs. len ( ) {
985- 1 => ( strs. pop ( ) . unwrap ( ) , String :: new ( ) ) ,
986- 2 => {
987- let end = strs. pop ( ) . unwrap ( ) ;
988- ( strs. pop ( ) . unwrap ( ) , end)
989- }
990- n => panic ! ( "Expected 1 or 2 strings, not {}" , n) ,
991- }
982+ // FIXME(Zalathar): The form without `=` seems to be unused; should
983+ // we drop support for it?
984+ let ( name, value) = nv. split_once ( '=' ) . unwrap_or ( ( & nv, "" ) ) ;
985+ // Trim whitespace from the name, so that `//@ exec-env: FOO=BAR`
986+ // sees the name as `FOO` and not ` FOO`.
987+ let name = name. trim ( ) ;
988+ ( name. to_owned ( ) , value. to_owned ( ) )
992989 }
993990
994991 fn parse_pp_exact ( & self , line : & str , testfile : & Path ) -> Option < PathBuf > {
0 commit comments