File tree 3 files changed +24
-9
lines changed
compiler/rustc_feature/src
3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -74,14 +74,19 @@ impl UnstableFeatures {
74
74
// Returns whether `krate` should be counted as unstable
75
75
let is_unstable_crate =
76
76
|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 ( ref val) = bootstrap {
80
+ match val. as_str ( ) {
81
+ val if val == "1" || is_unstable_crate ( val) => return UnstableFeatures :: Cheat ,
82
+ // Hypnotize ourselves to so we are a stable compiler and thus don't allow any
83
+ // unstable features.
84
+ "-1" => return UnstableFeatures :: Disallow ,
85
+ _ => { }
86
+ }
84
87
}
88
+
89
+ if disable_unstable_features { UnstableFeatures :: Disallow } else { UnstableFeatures :: Allow }
85
90
}
86
91
87
92
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() {
18
18
assert ! ( !is_bootstrap( "x,y,z" , Some ( "a" ) ) ) ;
19
19
assert ! ( !is_bootstrap( "x,y,z" , None ) ) ;
20
20
21
- // this is technically a breaking change, but there are no stability guarantees for RUSTC_BOOTSTRAP
21
+ // `RUSTC_BOOTSTRAP=0` is not recognized.
22
22
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" ) ) ) ;
23
33
}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ pub struct EnabledLangFeature {
54
54
pub stable_since : Option < Symbol > ,
55
55
}
56
56
57
- /// Information abhout an enabled library feature.
57
+ /// Information about an enabled library feature.
58
58
#[ derive( Debug , Copy , Clone ) ]
59
59
pub struct EnabledLibFeature {
60
60
pub gate_name : Symbol ,
You can’t perform that action at this time.
0 commit comments