about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-04-01 08:18:10 +0200
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-04-10 14:40:25 +0200
commite82b6c42b47ef9cadf2d86395fde3a3d9d5ff628 (patch)
tree8b4e7ea0cac66a9f195f62092e46ac94262d3525
parent27adb31fcc2e31ca5528112260a5981fa91d687e (diff)
downloadrust-e82b6c42b47ef9cadf2d86395fde3a3d9d5ff628.tar.gz
rust-e82b6c42b47ef9cadf2d86395fde3a3d9d5ff628.zip
Make Session.plugin_registrar_fn and Session.derive_registrar_fn thread-safe
-rw-r--r--src/librustc/session/mod.rs8
-rw-r--r--src/librustc_trans/back/symbol_export.rs4
-rw-r--r--src/librustc_trans_utils/symbol_names.rs4
3 files changed, 8 insertions, 8 deletions
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index 97b73fac1a4..8d3215e69cd 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -71,8 +71,8 @@ pub struct Session {
     pub parse_sess: ParseSess,
     /// For a library crate, this is always none
     pub entry_fn: Once<Option<(NodeId, Span, config::EntryFnType)>>,
-    pub plugin_registrar_fn: Cell<Option<ast::NodeId>>,
-    pub derive_registrar_fn: Cell<Option<ast::NodeId>>,
+    pub plugin_registrar_fn: Once<Option<ast::NodeId>>,
+    pub derive_registrar_fn: Once<Option<ast::NodeId>>,
     pub default_sysroot: Option<PathBuf>,
     /// The name of the root source file of the crate, in the local file system.
     /// `None` means that there is no source file.
@@ -1094,8 +1094,8 @@ pub fn build_session_(
         parse_sess: p_s,
         // For a library crate, this is always none
         entry_fn: Once::new(),
-        plugin_registrar_fn: Cell::new(None),
-        derive_registrar_fn: Cell::new(None),
+        plugin_registrar_fn: Once::new(),
+        derive_registrar_fn: Once::new(),
         default_sysroot,
         local_crate_source_file,
         working_dir,
diff --git a/src/librustc_trans/back/symbol_export.rs b/src/librustc_trans/back/symbol_export.rs
index acd2a765730..965a34eccb8 100644
--- a/src/librustc_trans/back/symbol_export.rs
+++ b/src/librustc_trans/back/symbol_export.rs
@@ -157,12 +157,12 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         })
         .collect();
 
-    if let Some(id) = tcx.sess.derive_registrar_fn.get() {
+    if let Some(id) = *tcx.sess.derive_registrar_fn.get() {
         let def_id = tcx.hir.local_def_id(id);
         reachable_non_generics.insert(def_id, SymbolExportLevel::C);
     }
 
-    if let Some(id) = tcx.sess.plugin_registrar_fn.get() {
+    if let Some(id) = *tcx.sess.plugin_registrar_fn.get() {
         let def_id = tcx.hir.local_def_id(id);
         reachable_non_generics.insert(def_id, SymbolExportLevel::C);
     }
diff --git a/src/librustc_trans_utils/symbol_names.rs b/src/librustc_trans_utils/symbol_names.rs
index af174f7ce85..f3b7326b210 100644
--- a/src/librustc_trans_utils/symbol_names.rs
+++ b/src/librustc_trans_utils/symbol_names.rs
@@ -244,11 +244,11 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
     let node_id = tcx.hir.as_local_node_id(def_id);
 
     if let Some(id) = node_id {
-        if tcx.sess.plugin_registrar_fn.get() == Some(id) {
+        if *tcx.sess.plugin_registrar_fn.get() == Some(id) {
             let disambiguator = tcx.sess.local_crate_disambiguator();
             return tcx.sess.generate_plugin_registrar_symbol(disambiguator);
         }
-        if tcx.sess.derive_registrar_fn.get() == Some(id) {
+        if *tcx.sess.derive_registrar_fn.get() == Some(id) {
             let disambiguator = tcx.sess.local_crate_disambiguator();
             return tcx.sess.generate_derive_registrar_symbol(disambiguator);
         }