Skip to content

Commit c979189

Browse files
committed
Make ParseSess thread-safe
1 parent 3f0cb8c commit c979189

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/libsyntax/parse/lexer/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,6 @@ mod tests {
17811781
use errors;
17821782
use feature_gate::UnstableFeatures;
17831783
use parse::token;
1784-
use std::cell::RefCell;
17851784
use std::collections::HashSet;
17861785
use std::io;
17871786
use std::path::PathBuf;
@@ -1797,12 +1796,12 @@ mod tests {
17971796
span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)),
17981797
unstable_features: UnstableFeatures::from_environment(),
17991798
config: CrateConfig::new(),
1800-
included_mod_stack: RefCell::new(Vec::new()),
1799+
included_mod_stack: Lock::new(Vec::new()),
18011800
code_map: cm,
1802-
missing_fragment_specifiers: RefCell::new(HashSet::new()),
1803-
raw_identifier_spans: RefCell::new(Vec::new()),
1801+
missing_fragment_specifiers: Lock::new(HashSet::new()),
1802+
raw_identifier_spans: Lock::new(Vec::new()),
18041803
registered_diagnostics: Lock::new(ErrorMap::new()),
1805-
non_modrs_mods: RefCell::new(vec![]),
1804+
non_modrs_mods: Lock::new(vec![]),
18061805
}
18071806
}
18081807

src/libsyntax/parse/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use symbol::Symbol;
2323
use tokenstream::{TokenStream, TokenTree};
2424
use diagnostics::plugin::ErrorMap;
2525

26-
use std::cell::RefCell;
2726
use std::collections::HashSet;
2827
use std::iter;
2928
use std::path::{Path, PathBuf};
@@ -47,17 +46,17 @@ pub struct ParseSess {
4746
pub span_diagnostic: Handler,
4847
pub unstable_features: UnstableFeatures,
4948
pub config: CrateConfig,
50-
pub missing_fragment_specifiers: RefCell<HashSet<Span>>,
49+
pub missing_fragment_specifiers: Lock<HashSet<Span>>,
5150
/// Places where raw identifiers were used. This is used for feature gating
5251
/// raw identifiers
53-
pub raw_identifier_spans: RefCell<Vec<Span>>,
52+
pub raw_identifier_spans: Lock<Vec<Span>>,
5453
/// The registered diagnostics codes
5554
pub registered_diagnostics: Lock<ErrorMap>,
5655
// Spans where a `mod foo;` statement was included in a non-mod.rs file.
5756
// These are used to issue errors if the non_modrs_mods feature is not enabled.
58-
pub non_modrs_mods: RefCell<Vec<(ast::Ident, Span)>>,
57+
pub non_modrs_mods: Lock<Vec<(ast::Ident, Span)>>,
5958
/// Used to determine and report recursive mod inclusions
60-
included_mod_stack: RefCell<Vec<PathBuf>>,
59+
included_mod_stack: Lock<Vec<PathBuf>>,
6160
code_map: Lrc<CodeMap>,
6261
}
6362

@@ -76,12 +75,12 @@ impl ParseSess {
7675
span_diagnostic: handler,
7776
unstable_features: UnstableFeatures::from_environment(),
7877
config: HashSet::new(),
79-
missing_fragment_specifiers: RefCell::new(HashSet::new()),
80-
raw_identifier_spans: RefCell::new(Vec::new()),
78+
missing_fragment_specifiers: Lock::new(HashSet::new()),
79+
raw_identifier_spans: Lock::new(Vec::new()),
8180
registered_diagnostics: Lock::new(ErrorMap::new()),
82-
included_mod_stack: RefCell::new(vec![]),
81+
included_mod_stack: Lock::new(vec![]),
8382
code_map,
84-
non_modrs_mods: RefCell::new(vec![]),
83+
non_modrs_mods: Lock::new(vec![]),
8584
}
8685
}
8786

0 commit comments

Comments
 (0)