Skip to content

Commit 271c8d3

Browse files
committed
Make Session.crate_disambiguator thread-safe
1 parent 8380539 commit 271c8d3

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/librustc/session/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub struct Session {
9999
/// forms a unique global identifier for the crate. It is used to allow
100100
/// multiple crates with the same name to coexist. See the
101101
/// trans::back::symbol_names module for more information.
102-
pub crate_disambiguator: RefCell<Option<CrateDisambiguator>>,
102+
pub crate_disambiguator: Once<CrateDisambiguator>,
103103

104104
features: Once<feature_gate::Features>,
105105

@@ -202,10 +202,7 @@ impl From<&'static lint::Lint> for DiagnosticMessageId {
202202

203203
impl Session {
204204
pub fn local_crate_disambiguator(&self) -> CrateDisambiguator {
205-
match *self.crate_disambiguator.borrow() {
206-
Some(value) => value,
207-
None => bug!("accessing disambiguator before initialization"),
208-
}
205+
*self.crate_disambiguator.get()
209206
}
210207

211208
pub fn struct_span_warn<'a, S: Into<MultiSpan>>(
@@ -1101,7 +1098,7 @@ pub fn build_session_(
11011098
plugin_attributes: RefCell::new(Vec::new()),
11021099
crate_types: RefCell::new(Vec::new()),
11031100
dependency_formats: RefCell::new(FxHashMap()),
1104-
crate_disambiguator: RefCell::new(None),
1101+
crate_disambiguator: Once::new(),
11051102
features: Once::new(),
11061103
recursion_limit: Once::new(),
11071104
type_length_limit: Once::new(),

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
655655
*sess.crate_types.borrow_mut() = collect_crate_types(sess, &krate.attrs);
656656

657657
let disambiguator = compute_crate_disambiguator(sess);
658-
*sess.crate_disambiguator.borrow_mut() = Some(disambiguator);
658+
sess.crate_disambiguator.set(disambiguator);
659659
rustc_incremental::prepare_session_directory(
660660
sess,
661661
&crate_name,

0 commit comments

Comments
 (0)