File tree Expand file tree Collapse file tree 3 files changed +24
-9
lines changed
compiler/rustc_feature/src Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -74,14 +74,19 @@ impl UnstableFeatures {
7474 // Returns whether `krate` should be counted as unstable
7575 let is_unstable_crate =
7676 |var : & str | krate. is_some_and ( |name| var. split ( ',' ) . any ( |new_krate| new_krate == name) ) ;
77- // `true` if we should enable unstable features for bootstrapping.
78- let bootstrap =
79- std:: env:: var ( "RUSTC_BOOTSTRAP" ) . is_ok_and ( |var| var == "1" || is_unstable_crate ( & var) ) ;
80- match ( disable_unstable_features, bootstrap) {
81- ( _, true ) => UnstableFeatures :: Cheat ,
82- ( true , _) => UnstableFeatures :: Disallow ,
83- ( false , _) => UnstableFeatures :: Allow ,
77+
78+ let bootstrap = std:: env:: var ( "RUSTC_BOOTSTRAP" ) . ok ( ) ;
79+ if let Some ( val) = bootstrap. as_deref ( ) {
80+ match val {
81+ val if val == "1" || is_unstable_crate ( val) => return UnstableFeatures :: Cheat ,
82+ // Hypnotize ourselves so that we think we are a stable compiler and thus don't
83+ // allow any unstable features.
84+ "-1" => return UnstableFeatures :: Disallow ,
85+ _ => { }
86+ }
8487 }
88+
89+ if disable_unstable_features { UnstableFeatures :: Disallow } else { UnstableFeatures :: Allow }
8590 }
8691
8792 pub fn is_nightly_build ( & self ) -> bool {
Original file line number Diff line number Diff line change @@ -18,6 +18,16 @@ fn rustc_bootstrap_parsing() {
1818 assert ! ( !is_bootstrap( "x,y,z" , Some ( "a" ) ) ) ;
1919 assert ! ( !is_bootstrap( "x,y,z" , None ) ) ;
2020
21- // this is technically a breaking change, but there are no stability guarantees for RUSTC_BOOTSTRAP
21+ // `RUSTC_BOOTSTRAP=0` is not recognized.
2222 assert ! ( !is_bootstrap( "0" , None ) ) ;
23+
24+ // `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+ } ;
29+ assert ! ( is_force_stable( None ) ) ;
30+ // Does not support specifying any crate.
31+ assert ! ( is_force_stable( Some ( "x" ) ) ) ;
32+ assert ! ( is_force_stable( Some ( "x,y,z" ) ) ) ;
2333}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ pub struct EnabledLangFeature {
5454 pub stable_since : Option < Symbol > ,
5555}
5656
57- /// Information abhout an enabled library feature.
57+ /// Information about an enabled library feature.
5858#[ derive( Debug , Copy , Clone ) ]
5959pub struct EnabledLibFeature {
6060 pub gate_name : Symbol ,
You can’t perform that action at this time.
0 commit comments