]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #49882 - Zoxc:sync-misc2, r=michaelwoerister
authorbors <bors@rust-lang.org>
Tue, 17 Apr 2018 06:46:31 +0000 (06:46 +0000)
committerbors <bors@rust-lang.org>
Tue, 17 Apr 2018 06:46:31 +0000 (06:46 +0000)
More thread-safety changes

r? @michaelwoerister

1  2 
src/librustc/session/mod.rs
src/librustc_driver/driver.rs

index 32de006459d32ca1837ad9ed54c93ae5f93b3269,77dff0950ee58268a562f8e24c189c4130b8102f..696bd736594d4bd6a685bb4fb5cea0e79293b535
@@@ -26,7 -26,7 +26,7 @@@ use util::nodemap::{FxHashSet}
  use util::common::{duration_to_secs_str, ErrorReported};
  use util::common::ProfileQueriesMsg;
  
- use rustc_data_structures::sync::{Lrc, Lock, LockCell, OneThread, Once};
+ use rustc_data_structures::sync::{Lrc, Lock, LockCell, OneThread, Once, RwLock};
  
  use syntax::ast::NodeId;
  use errors::{self, DiagnosticBuilder, DiagnosticId};
@@@ -83,8 -83,8 +83,8 @@@ pub struct Session 
  
      // FIXME: lint_store and buffered_lints are not thread-safe,
      // but are only used in a single thread
-     pub lint_store: OneThread<RefCell<lint::LintStore>>,
-     pub buffered_lints: OneThread<RefCell<Option<lint::LintBuffer>>>,
+     pub lint_store: RwLock<lint::LintStore>,
+     pub buffered_lints: Lock<Option<lint::LintBuffer>>,
  
      /// Set of (DiagnosticId, Option<Span>, message) tuples tracking
      /// (sub)diagnostics that have been set once, but should not be set again,
  
      /// The maximum number of stackframes allowed in const eval
      pub const_eval_stack_frame_limit: usize,
 -    /// The maximum number miri steps per constant
 -    pub const_eval_step_limit: usize,
  
      /// The metadata::creader module may inject an allocator/panic_runtime
      /// dependency if it didn't already find one, and this tracks what was
@@@ -1089,8 -1091,8 +1089,8 @@@ pub fn build_session_
          default_sysroot,
          local_crate_source_file,
          working_dir,
-         lint_store: OneThread::new(RefCell::new(lint::LintStore::new())),
-         buffered_lints: OneThread::new(RefCell::new(Some(lint::LintBuffer::new()))),
+         lint_store: RwLock::new(lint::LintStore::new()),
+         buffered_lints: Lock::new(Some(lint::LintBuffer::new())),
          one_time_diagnostics: RefCell::new(FxHashSet()),
          plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
          plugin_attributes: OneThread::new(RefCell::new(Vec::new())),
          recursion_limit: Once::new(),
          type_length_limit: Once::new(),
          const_eval_stack_frame_limit: 100,
 -        const_eval_step_limit: 1_000_000,
          next_node_id: OneThread::new(Cell::new(NodeId::new(1))),
          injected_allocator: Once::new(),
          allocator_kind: Once::new(),
index fe89be11764e83e1ea1eca135aa038189aa4a2b5,ad25e834c479e41a4a476797d1d8b3b72336386d..a0eed9e2f8ce8aad480f5c2faf38896bec68c4ec
@@@ -168,7 -168,7 +168,7 @@@ pub fn compile_input(trans: Box<TransCr
  
          write_out_deps(sess, &outputs, &output_paths);
          if sess.opts.output_types.contains_key(&OutputType::DepInfo) &&
 -            sess.opts.output_types.keys().count() == 1 {
 +            sess.opts.output_types.len() == 1 {
              return Ok(())
          }
  
@@@ -793,9 -793,13 +793,13 @@@ pub fn phase_2_configure_and_expand_inn
          let mut ecx = ExtCtxt::new(&sess.parse_sess, cfg, &mut resolver);
          let err_count = ecx.parse_sess.span_diagnostic.err_count();
  
-         let krate = ecx.monotonic_expander().expand_crate(krate);
+         let krate = time(sess, "expand crate", || {
+             ecx.monotonic_expander().expand_crate(krate)
+         });
  
-         ecx.check_unused_macros();
+         time(sess, "check unused macros", || {
+             ecx.check_unused_macros();
+         });
  
          let mut missing_fragment_specifiers: Vec<_> =
              ecx.parse_sess.missing_fragment_specifiers.borrow().iter().cloned().collect();