diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2019-04-06 00:15:49 +0200 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2019-05-21 18:17:05 +0200 |
| commit | a1f2dceaebd21a6f8a5f9341bf41724bb20e2a7d (patch) | |
| tree | 92928e104879c4c6aa37de8717d1c339999f35b1 /src/librustc_interface | |
| parent | 50a0defd5a93523067ef239936cc2e0755220904 (diff) | |
| download | rust-a1f2dceaebd21a6f8a5f9341bf41724bb20e2a7d.tar.gz rust-a1f2dceaebd21a6f8a5f9341bf41724bb20e2a7d.zip | |
Move `edition` outside the hygiene lock and avoid accessing it
Diffstat (limited to 'src/librustc_interface')
| -rw-r--r-- | src/librustc_interface/interface.rs | 4 | ||||
| -rw-r--r-- | src/librustc_interface/passes.rs | 6 | ||||
| -rw-r--r-- | src/librustc_interface/util.rs | 7 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index f2a21d61aed..d598a48649e 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -18,6 +18,7 @@ use std::result; use std::sync::{Arc, Mutex}; use syntax; use syntax::source_map::{FileLoader, SourceMap}; +use syntax_pos::edition; pub type Result<T> = result::Result<T, ErrorReported>; @@ -135,6 +136,7 @@ where { let stderr = config.stderr.take(); util::spawn_thread_pool( + config.opts.edition, config.opts.debugging_opts.threads, &stderr, || run_compiler_in_existing_thread_pool(config, f), @@ -146,5 +148,5 @@ where F: FnOnce() -> R + Send, R: Send, { - util::spawn_thread_pool(None, &None, f) + util::spawn_thread_pool(edition::DEFAULT_EDITION, None, &None, f) } diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index c5ac8860ccd..04041f88344 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -48,7 +48,7 @@ use syntax::util::node_count::NodeCounter; use syntax::util::lev_distance::find_best_match_for_name; use syntax::symbol::Symbol; use syntax::feature_gate::AttributeType; -use syntax_pos::{FileName, hygiene}; +use syntax_pos::{FileName, edition::Edition, hygiene}; use syntax_ext; use serialize::json; @@ -70,8 +70,6 @@ use std::ops::Generator; pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> { sess.diagnostic() .set_continue_after_error(sess.opts.debugging_opts.continue_parse_after_error); - hygiene::set_default_edition(sess.edition()); - sess.profiler(|p| p.start_activity("parsing")); let krate = time(sess, "parsing", || match *input { Input::File(ref file) => parse::parse_crate_from_file(file, &sess.parse_sess), @@ -375,7 +373,7 @@ fn configure_and_expand_inner<'a>( crate_loader, &resolver_arenas, ); - syntax_ext::register_builtins(&mut resolver, plugin_info.syntax_exts); + syntax_ext::register_builtins(&mut resolver, plugin_info.syntax_exts, sess.edition()); // Expand all macros sess.profiler(|p| p.start_activity("macro expansion")); diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index d2d0d191807..09bb547191f 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -37,6 +37,7 @@ use syntax::util::lev_distance::find_best_match_for_name; use syntax::source_map::{FileLoader, RealFileLoader, SourceMap}; use syntax::symbol::{Symbol, sym}; use syntax::{self, ast, attr}; +use syntax_pos::edition::Edition; #[cfg(not(parallel_compiler))] use std::{thread, panic}; @@ -167,6 +168,7 @@ pub fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f: #[cfg(not(parallel_compiler))] pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>( + edition: Edition, _threads: Option<usize>, stderr: &Option<Arc<Mutex<Vec<u8>>>>, f: F, @@ -178,7 +180,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>( } scoped_thread(cfg, || { - syntax::with_globals( || { + syntax::with_globals(edition, || { ty::tls::GCX_PTR.set(&Lock::new(0), || { if let Some(stderr) = stderr { io::set_panic(Some(box Sink(stderr.clone()))); @@ -191,6 +193,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>( #[cfg(parallel_compiler)] pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>( + edition: Edition, threads: Option<usize>, stderr: &Option<Arc<Mutex<Vec<u8>>>>, f: F, @@ -213,7 +216,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>( let with_pool = move |pool: &ThreadPool| pool.install(move || f()); - syntax::with_globals(|| { + syntax::with_globals(edition, || { syntax::GLOBALS.with(|syntax_globals| { syntax_pos::GLOBALS.with(|syntax_pos_globals| { // The main handler runs for each Rayon worker thread and sets up |
