@@ -2391,6 +2391,7 @@ mod tests {
23912391 use super :: { Externs , OutputType , OutputTypes } ;
23922392 use rustc_back:: { PanicStrategy , RelroLevel } ;
23932393 use syntax:: symbol:: Symbol ;
2394+ use syntax;
23942395
23952396 fn optgroups ( ) -> getopts:: Options {
23962397 let mut opts = getopts:: Options :: new ( ) ;
@@ -2411,61 +2412,66 @@ mod tests {
24112412 // When the user supplies --test we should implicitly supply --cfg test
24122413 #[ test]
24132414 fn test_switch_implies_cfg_test ( ) {
2414- let matches = & match optgroups ( ) . parse ( & [ "--test" . to_string ( ) ] ) {
2415- Ok ( m) => m,
2416- Err ( f) => panic ! ( "test_switch_implies_cfg_test: {}" , f) ,
2417- } ;
2418- let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2419- let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
2420- let sess = build_session ( sessopts, None , registry) ;
2421- let cfg = build_configuration ( & sess, cfg) ;
2422- assert ! ( cfg. contains( & ( Symbol :: intern( "test" ) , None ) ) ) ;
2415+ syntax:: with_globals ( || {
2416+ let matches = & match optgroups ( ) . parse ( & [ "--test" . to_string ( ) ] ) {
2417+ Ok ( m) => m,
2418+ Err ( f) => panic ! ( "test_switch_implies_cfg_test: {}" , f) ,
2419+ } ;
2420+ let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2421+ let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
2422+ let sess = build_session ( sessopts, None , registry) ;
2423+ let cfg = build_configuration ( & sess, cfg) ;
2424+ assert ! ( cfg. contains( & ( Symbol :: intern( "test" ) , None ) ) ) ;
2425+ } ) ;
24232426 }
24242427
24252428 // When the user supplies --test and --cfg test, don't implicitly add
24262429 // another --cfg test
24272430 #[ test]
24282431 fn test_switch_implies_cfg_test_unless_cfg_test ( ) {
2429- let matches = & match optgroups ( ) . parse ( & [ "--test" . to_string ( ) , "--cfg=test" . to_string ( ) ] ) {
2430- Ok ( m) => m,
2431- Err ( f) => panic ! ( "test_switch_implies_cfg_test_unless_cfg_test: {}" , f) ,
2432- } ;
2433- let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2434- let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
2435- let sess = build_session ( sessopts, None , registry) ;
2436- let cfg = build_configuration ( & sess, cfg) ;
2437- let mut test_items = cfg. iter ( ) . filter ( |& & ( name, _) | name == "test" ) ;
2438- assert ! ( test_items. next( ) . is_some( ) ) ;
2439- assert ! ( test_items. next( ) . is_none( ) ) ;
2432+ syntax:: with_globals ( || {
2433+ let matches = & match optgroups ( ) . parse ( & [ "--test" . to_string ( ) ,
2434+ "--cfg=test" . to_string ( ) ] ) {
2435+ Ok ( m) => m,
2436+ Err ( f) => panic ! ( "test_switch_implies_cfg_test_unless_cfg_test: {}" , f) ,
2437+ } ;
2438+ let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2439+ let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
2440+ let sess = build_session ( sessopts, None , registry) ;
2441+ let cfg = build_configuration ( & sess, cfg) ;
2442+ let mut test_items = cfg. iter ( ) . filter ( |& & ( name, _) | name == "test" ) ;
2443+ assert ! ( test_items. next( ) . is_some( ) ) ;
2444+ assert ! ( test_items. next( ) . is_none( ) ) ;
2445+ } ) ;
24402446 }
24412447
24422448 #[ test]
24432449 fn test_can_print_warnings ( ) {
2444- {
2450+ syntax :: with_globals ( || {
24452451 let matches = optgroups ( ) . parse ( & [ "-Awarnings" . to_string ( ) ] ) . unwrap ( ) ;
24462452 let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
24472453 let ( sessopts, _) = build_session_options_and_crate_config ( & matches) ;
24482454 let sess = build_session ( sessopts, None , registry) ;
24492455 assert ! ( !sess. diagnostic( ) . flags. can_emit_warnings) ;
2450- }
2456+ } ) ;
24512457
2452- {
2458+ syntax :: with_globals ( || {
24532459 let matches = optgroups ( )
24542460 . parse ( & [ "-Awarnings" . to_string ( ) , "-Dwarnings" . to_string ( ) ] )
24552461 . unwrap ( ) ;
24562462 let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
24572463 let ( sessopts, _) = build_session_options_and_crate_config ( & matches) ;
24582464 let sess = build_session ( sessopts, None , registry) ;
24592465 assert ! ( sess. diagnostic( ) . flags. can_emit_warnings) ;
2460- }
2466+ } ) ;
24612467
2462- {
2468+ syntax :: with_globals ( || {
24632469 let matches = optgroups ( ) . parse ( & [ "-Adead_code" . to_string ( ) ] ) . unwrap ( ) ;
24642470 let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
24652471 let ( sessopts, _) = build_session_options_and_crate_config ( & matches) ;
24662472 let sess = build_session ( sessopts, None , registry) ;
24672473 assert ! ( sess. diagnostic( ) . flags. can_emit_warnings) ;
2468- }
2474+ } ) ;
24692475 }
24702476
24712477 #[ test]
0 commit comments