@@ -101,7 +101,7 @@ pub struct Session {
101
101
/// trans::back::symbol_names module for more information.
102
102
pub crate_disambiguator : RefCell < Option < CrateDisambiguator > > ,
103
103
104
- features : RefCell < Option < feature_gate:: Features > > ,
104
+ features : Once < feature_gate:: Features > ,
105
105
106
106
/// The maximum recursion limit for potentially infinitely recursive
107
107
/// operations such as auto-dereference and monomorphization.
@@ -532,18 +532,12 @@ impl Session {
532
532
/// DO NOT USE THIS METHOD if there is a TyCtxt available, as it circumvents
533
533
/// dependency tracking. Use tcx.features() instead.
534
534
#[ inline]
535
- pub fn features_untracked ( & self ) -> cell:: Ref < feature_gate:: Features > {
536
- let features = self . features . borrow ( ) ;
537
-
538
- if features. is_none ( ) {
539
- bug ! ( "Access to Session::features before it is initialized" ) ;
540
- }
541
-
542
- cell:: Ref :: map ( features, |r| r. as_ref ( ) . unwrap ( ) )
535
+ pub fn features_untracked ( & self ) -> & feature_gate:: Features {
536
+ self . features . get ( )
543
537
}
544
538
545
539
pub fn init_features ( & self , features : feature_gate:: Features ) {
546
- * ( self . features . borrow_mut ( ) ) = Some ( features) ;
540
+ self . features . set ( features) ;
547
541
}
548
542
549
543
/// Calculates the flavor of LTO to use for this compilation.
@@ -1108,7 +1102,7 @@ pub fn build_session_(
1108
1102
crate_types : RefCell :: new ( Vec :: new ( ) ) ,
1109
1103
dependency_formats : RefCell :: new ( FxHashMap ( ) ) ,
1110
1104
crate_disambiguator : RefCell :: new ( None ) ,
1111
- features : RefCell :: new ( None ) ,
1105
+ features : Once :: new ( ) ,
1112
1106
recursion_limit : Once :: new ( ) ,
1113
1107
type_length_limit : Once :: new ( ) ,
1114
1108
const_eval_stack_frame_limit : 100 ,
0 commit comments