Skip to content

Commit e82b6c4

Browse files
committed
Make Session.plugin_registrar_fn and Session.derive_registrar_fn thread-safe
1 parent 27adb31 commit e82b6c4

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/librustc/session/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ pub struct Session {
7171
pub parse_sess: ParseSess,
7272
/// For a library crate, this is always none
7373
pub entry_fn: Once<Option<(NodeId, Span, config::EntryFnType)>>,
74-
pub plugin_registrar_fn: Cell<Option<ast::NodeId>>,
75-
pub derive_registrar_fn: Cell<Option<ast::NodeId>>,
74+
pub plugin_registrar_fn: Once<Option<ast::NodeId>>,
75+
pub derive_registrar_fn: Once<Option<ast::NodeId>>,
7676
pub default_sysroot: Option<PathBuf>,
7777
/// The name of the root source file of the crate, in the local file system.
7878
/// `None` means that there is no source file.
@@ -1094,8 +1094,8 @@ pub fn build_session_(
10941094
parse_sess: p_s,
10951095
// For a library crate, this is always none
10961096
entry_fn: Once::new(),
1097-
plugin_registrar_fn: Cell::new(None),
1098-
derive_registrar_fn: Cell::new(None),
1097+
plugin_registrar_fn: Once::new(),
1098+
derive_registrar_fn: Once::new(),
10991099
default_sysroot,
11001100
local_crate_source_file,
11011101
working_dir,

src/librustc_trans/back/symbol_export.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
157157
})
158158
.collect();
159159

160-
if let Some(id) = tcx.sess.derive_registrar_fn.get() {
160+
if let Some(id) = *tcx.sess.derive_registrar_fn.get() {
161161
let def_id = tcx.hir.local_def_id(id);
162162
reachable_non_generics.insert(def_id, SymbolExportLevel::C);
163163
}
164164

165-
if let Some(id) = tcx.sess.plugin_registrar_fn.get() {
165+
if let Some(id) = *tcx.sess.plugin_registrar_fn.get() {
166166
let def_id = tcx.hir.local_def_id(id);
167167
reachable_non_generics.insert(def_id, SymbolExportLevel::C);
168168
}

src/librustc_trans_utils/symbol_names.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
244244
let node_id = tcx.hir.as_local_node_id(def_id);
245245

246246
if let Some(id) = node_id {
247-
if tcx.sess.plugin_registrar_fn.get() == Some(id) {
247+
if *tcx.sess.plugin_registrar_fn.get() == Some(id) {
248248
let disambiguator = tcx.sess.local_crate_disambiguator();
249249
return tcx.sess.generate_plugin_registrar_symbol(disambiguator);
250250
}
251-
if tcx.sess.derive_registrar_fn.get() == Some(id) {
251+
if *tcx.sess.derive_registrar_fn.get() == Some(id) {
252252
let disambiguator = tcx.sess.local_crate_disambiguator();
253253
return tcx.sess.generate_derive_registrar_symbol(disambiguator);
254254
}

0 commit comments

Comments
 (0)