Skip to content

Commit 49a2b80

Browse files
committed
Make sure the lint store is only used on one thread
1 parent 26f16e8 commit 49a2b80

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/librustc/session/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use util::nodemap::{FxHashMap, FxHashSet};
2626
use util::common::{duration_to_secs_str, ErrorReported};
2727
use util::common::ProfileQueriesMsg;
2828

29-
use rustc_data_structures::sync::{Lrc, Lock};
29+
use rustc_data_structures::sync::{Lrc, Lock, OneThread};
3030

3131
use syntax::ast::NodeId;
3232
use errors::{self, DiagnosticBuilder, DiagnosticId};
@@ -80,8 +80,12 @@ pub struct Session {
8080
/// The directory the compiler has been executed in plus a flag indicating
8181
/// if the value stored here has been affected by path remapping.
8282
pub working_dir: (PathBuf, bool),
83-
pub lint_store: RefCell<lint::LintStore>,
84-
pub buffered_lints: RefCell<Option<lint::LintBuffer>>,
83+
84+
// FIXME: lint_store and buffered_lints are not thread-safe,
85+
// but are only used in a single thread
86+
pub lint_store: OneThread<RefCell<lint::LintStore>>,
87+
pub buffered_lints: OneThread<RefCell<Option<lint::LintBuffer>>>,
88+
8589
/// Set of (DiagnosticId, Option<Span>, message) tuples tracking
8690
/// (sub)diagnostics that have been set once, but should not be set again,
8791
/// in order to avoid redundantly verbose output (Issue #24690, #44953).
@@ -1134,8 +1138,8 @@ pub fn build_session_(
11341138
default_sysroot,
11351139
local_crate_source_file,
11361140
working_dir,
1137-
lint_store: RefCell::new(lint::LintStore::new()),
1138-
buffered_lints: RefCell::new(Some(lint::LintBuffer::new())),
1141+
lint_store: OneThread::new(RefCell::new(lint::LintStore::new())),
1142+
buffered_lints: OneThread::new(RefCell::new(Some(lint::LintBuffer::new()))),
11391143
one_time_diagnostics: RefCell::new(FxHashSet()),
11401144
plugin_llvm_passes: RefCell::new(Vec::new()),
11411145
plugin_attributes: RefCell::new(Vec::new()),

0 commit comments

Comments
 (0)