syntax: reexport attr globals

This commit is contained in:
Mazdak Farrokhzad 2020-01-18 18:57:06 +01:00
parent f882b07977
commit eadff06823
5 changed files with 8 additions and 7 deletions

View File

@ -3,7 +3,7 @@ use super::*;
use rustc_span;
use rustc_span::source_map::{dummy_spanned, respan};
use syntax::ast;
use syntax::attr::with_default_globals;
use syntax::with_default_globals;
fn fun_to_string(
decl: &ast::FnDecl,

View File

@ -65,7 +65,7 @@ impl Compiler {
/// Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`.
pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String>)> {
syntax::attr::with_default_globals(move || {
syntax::with_default_globals(move || {
let cfg = cfgspecs
.into_iter()
.map(|s| {

View File

@ -147,7 +147,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
crate::callbacks::setup_callbacks();
scoped_thread(cfg, || {
syntax::attr::with_globals(edition, || {
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())));
@ -183,15 +183,15 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
let with_pool = move |pool: &ThreadPool| pool.install(move || f());
syntax::attr::with_globals(edition, || {
syntax::attr::GLOBALS.with(|syntax_globals| {
syntax::with_globals(edition, || {
syntax::GLOBALS.with(|syntax_globals| {
rustc_span::GLOBALS.with(|rustc_span_globals| {
// The main handler runs for each Rayon worker thread and sets up
// the thread local rustc uses. syntax_globals and rustc_span_globals are
// captured and set on the new threads. ty::tls::with_thread_locals sets up
// thread local callbacks from libsyntax
let main_handler = move |thread: ThreadBuilder| {
syntax::attr::GLOBALS.set(syntax_globals, || {
syntax::GLOBALS.set(syntax_globals, || {
rustc_span::GLOBALS.set(rustc_span_globals, || {
if let Some(stderr) = stderr {
io::set_panic(Some(box Sink(stderr.clone())));

View File

@ -18,7 +18,7 @@ use std::path::PathBuf;
use std::process::{self, Command, Stdio};
use std::str;
use syntax::ast;
use syntax::attr::with_globals;
use syntax::with_globals;
use tempfile::Builder as TempFileBuilder;
use testing;

View File

@ -38,6 +38,7 @@ pub mod util {
pub mod ast;
pub mod attr;
pub use attr::{with_default_globals, with_globals, GLOBALS};
pub mod entry;
pub mod expand;
pub mod mut_visit;