Make Session::features_untracked thread-safe
This commit is contained in:
parent
a46f05978a
commit
904e2b6b35
@ -101,7 +101,7 @@ pub struct Session {
|
|||||||
/// trans::back::symbol_names module for more information.
|
/// trans::back::symbol_names module for more information.
|
||||||
pub crate_disambiguator: RefCell<Option<CrateDisambiguator>>,
|
pub crate_disambiguator: RefCell<Option<CrateDisambiguator>>,
|
||||||
|
|
||||||
features: RefCell<Option<feature_gate::Features>>,
|
features: Once<feature_gate::Features>,
|
||||||
|
|
||||||
/// The maximum recursion limit for potentially infinitely recursive
|
/// The maximum recursion limit for potentially infinitely recursive
|
||||||
/// operations such as auto-dereference and monomorphization.
|
/// operations such as auto-dereference and monomorphization.
|
||||||
@ -532,18 +532,12 @@ impl Session {
|
|||||||
/// DO NOT USE THIS METHOD if there is a TyCtxt available, as it circumvents
|
/// DO NOT USE THIS METHOD if there is a TyCtxt available, as it circumvents
|
||||||
/// dependency tracking. Use tcx.features() instead.
|
/// dependency tracking. Use tcx.features() instead.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn features_untracked(&self) -> cell::Ref<feature_gate::Features> {
|
pub fn features_untracked(&self) -> &feature_gate::Features {
|
||||||
let features = self.features.borrow();
|
self.features.get()
|
||||||
|
|
||||||
if features.is_none() {
|
|
||||||
bug!("Access to Session::features before it is initialized");
|
|
||||||
}
|
|
||||||
|
|
||||||
cell::Ref::map(features, |r| r.as_ref().unwrap())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_features(&self, features: feature_gate::Features) {
|
pub fn init_features(&self, features: feature_gate::Features) {
|
||||||
*(self.features.borrow_mut()) = Some(features);
|
self.features.set(features);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates the flavor of LTO to use for this compilation.
|
/// Calculates the flavor of LTO to use for this compilation.
|
||||||
@ -1108,7 +1102,7 @@ pub fn build_session_(
|
|||||||
crate_types: RefCell::new(Vec::new()),
|
crate_types: RefCell::new(Vec::new()),
|
||||||
dependency_formats: RefCell::new(FxHashMap()),
|
dependency_formats: RefCell::new(FxHashMap()),
|
||||||
crate_disambiguator: RefCell::new(None),
|
crate_disambiguator: RefCell::new(None),
|
||||||
features: RefCell::new(None),
|
features: Once::new(),
|
||||||
recursion_limit: Once::new(),
|
recursion_limit: Once::new(),
|
||||||
type_length_limit: Once::new(),
|
type_length_limit: Once::new(),
|
||||||
const_eval_stack_frame_limit: 100,
|
const_eval_stack_frame_limit: 100,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user