Use locks for Session.lint_store and Session.buffered_lints
This commit is contained in:
parent
2741690902
commit
fe63637350
2 changed files with 9 additions and 9 deletions
|
|
@ -27,6 +27,7 @@
|
|||
use self::TargetLint::*;
|
||||
|
||||
use std::slice;
|
||||
use rustc_data_structures::sync::{RwLock, ReadGuard};
|
||||
use lint::{EarlyLintPassObject, LateLintPassObject};
|
||||
use lint::{Level, Lint, LintId, LintPass, LintBuffer};
|
||||
use lint::builtin::BuiltinLintDiagnostics;
|
||||
|
|
@ -39,7 +40,6 @@ use ty::layout::{LayoutError, LayoutOf, TyLayout};
|
|||
use util::nodemap::FxHashMap;
|
||||
|
||||
use std::default::Default as StdDefault;
|
||||
use std::cell::{Ref, RefCell};
|
||||
use syntax::ast;
|
||||
use syntax::edition;
|
||||
use syntax_pos::{MultiSpan, Span};
|
||||
|
|
@ -78,7 +78,7 @@ pub struct LintStore {
|
|||
|
||||
pub struct LintSession<'a, PassObject> {
|
||||
/// Reference to the store of registered lints.
|
||||
lints: Ref<'a, LintStore>,
|
||||
lints: ReadGuard<'a, LintStore>,
|
||||
|
||||
/// Trait objects for each lint pass.
|
||||
passes: Option<Vec<PassObject>>,
|
||||
|
|
@ -336,7 +336,7 @@ impl<'a, PassObject: LintPassObject> LintSession<'a, PassObject> {
|
|||
/// Creates a new `LintSession`, by moving out the `LintStore`'s initial
|
||||
/// lint levels and pass objects. These can be restored using the `restore`
|
||||
/// method.
|
||||
fn new(store: &'a RefCell<LintStore>) -> LintSession<'a, PassObject> {
|
||||
fn new(store: &'a RwLock<LintStore>) -> LintSession<'a, PassObject> {
|
||||
let mut s = store.borrow_mut();
|
||||
let passes = PassObject::take_passes(&mut *s);
|
||||
drop(s);
|
||||
|
|
@ -347,7 +347,7 @@ impl<'a, PassObject: LintPassObject> LintSession<'a, PassObject> {
|
|||
}
|
||||
|
||||
/// Restores the levels back to the original lint store.
|
||||
fn restore(self, store: &RefCell<LintStore>) {
|
||||
fn restore(self, store: &RwLock<LintStore>) {
|
||||
drop(self.lints);
|
||||
let mut s = store.borrow_mut();
|
||||
PassObject::restore_passes(&mut *s, self.passes);
|
||||
|
|
|
|||
|
|
@ -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 @@ 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,
|
||||
|
|
@ -1091,8 +1091,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())),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue