1+ use std:: env;
2+
13use super :: UnstableFeatures ;
24
5+ fn unstable_features ( rustc_bootstrap : & str , crate_name : Option < & str > ) -> UnstableFeatures {
6+ UnstableFeatures :: from_environment_inner ( crate_name, |name| match name {
7+ "RUSTC_BOOTSTRAP" => Ok ( rustc_bootstrap. to_owned ( ) ) ,
8+ _ => Err ( env:: VarError :: NotPresent ) ,
9+ } )
10+ }
11+
312#[ test]
413fn rustc_bootstrap_parsing ( ) {
5- let is_bootstrap = |env, krate| {
6- std:: env:: set_var ( "RUSTC_BOOTSTRAP" , env) ;
7- matches ! ( UnstableFeatures :: from_environment( krate) , UnstableFeatures :: Cheat )
14+ let is_bootstrap = |rustc_bootstrap, crate_name| {
15+ matches ! ( unstable_features( rustc_bootstrap, crate_name) , UnstableFeatures :: Cheat )
816 } ;
917 assert ! ( is_bootstrap( "1" , None ) ) ;
1018 assert ! ( is_bootstrap( "1" , Some ( "x" ) ) ) ;
@@ -22,10 +30,8 @@ fn rustc_bootstrap_parsing() {
2230 assert ! ( !is_bootstrap( "0" , None ) ) ;
2331
2432 // `RUSTC_BOOTSTRAP=-1` is force-stable, no unstable features allowed.
25- let is_force_stable = |krate| {
26- std:: env:: set_var ( "RUSTC_BOOTSTRAP" , "-1" ) ;
27- matches ! ( UnstableFeatures :: from_environment( krate) , UnstableFeatures :: Disallow )
28- } ;
33+ let is_force_stable =
34+ |crate_name| matches ! ( unstable_features( "-1" , crate_name) , UnstableFeatures :: Disallow ) ;
2935 assert ! ( is_force_stable( None ) ) ;
3036 // Does not support specifying any crate.
3137 assert ! ( is_force_stable( Some ( "x" ) ) ) ;
0 commit comments