Skip to content

Commit 66488a5

Browse files
committed
Make Session.dependency_formats thread-safe
1 parent cbf8ad4 commit 66488a5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/librustc/middle/dependency_format.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ pub enum Linkage {
9494

9595
pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
9696
let sess = &tcx.sess;
97-
let mut fmts = sess.dependency_formats.borrow_mut();
97+
let mut fmts = FxHashMap();
9898
for &ty in sess.crate_types.borrow().iter() {
9999
let linkage = calculate_type(tcx, ty);
100100
verify_ok(tcx, &linkage);
101101
fmts.insert(ty, linkage);
102102
}
103103
sess.abort_if_errors();
104+
sess.dependency_formats.set(fmts);
104105
}
105106

106107
fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

src/librustc/session/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use middle::dependency_format;
2222
use session::search_paths::PathKind;
2323
use session::config::{DebugInfoLevel, OutputType};
2424
use ty::tls;
25-
use util::nodemap::{FxHashMap, FxHashSet};
25+
use util::nodemap::{FxHashSet};
2626
use util::common::{duration_to_secs_str, ErrorReported};
2727
use util::common::ProfileQueriesMsg;
2828

@@ -93,7 +93,7 @@ pub struct Session {
9393
pub plugin_llvm_passes: OneThread<RefCell<Vec<String>>>,
9494
pub plugin_attributes: OneThread<RefCell<Vec<(String, AttributeType)>>>,
9595
pub crate_types: Once<Vec<config::CrateType>>,
96-
pub dependency_formats: RefCell<dependency_format::Dependencies>,
96+
pub dependency_formats: Once<dependency_format::Dependencies>,
9797
/// The crate_disambiguator is constructed out of all the `-C metadata`
9898
/// arguments passed to the compiler. Its value together with the crate-name
9999
/// forms a unique global identifier for the crate. It is used to allow
@@ -1097,7 +1097,7 @@ pub fn build_session_(
10971097
plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
10981098
plugin_attributes: OneThread::new(RefCell::new(Vec::new())),
10991099
crate_types: Once::new(),
1100-
dependency_formats: RefCell::new(FxHashMap()),
1100+
dependency_formats: Once::new(),
11011101
crate_disambiguator: Once::new(),
11021102
features: Once::new(),
11031103
recursion_limit: Once::new(),

0 commit comments

Comments
 (0)