syntax: reexport attr globals
This commit is contained in:
parent
f882b07977
commit
eadff06823
5 changed files with 8 additions and 7 deletions
|
@ -3,7 +3,7 @@ use super::*;
|
||||||
use rustc_span;
|
use rustc_span;
|
||||||
use rustc_span::source_map::{dummy_spanned, respan};
|
use rustc_span::source_map::{dummy_spanned, respan};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr::with_default_globals;
|
use syntax::with_default_globals;
|
||||||
|
|
||||||
fn fun_to_string(
|
fn fun_to_string(
|
||||||
decl: &ast::FnDecl,
|
decl: &ast::FnDecl,
|
||||||
|
|
|
@ -65,7 +65,7 @@ impl Compiler {
|
||||||
|
|
||||||
/// Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`.
|
/// Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`.
|
||||||
pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String>)> {
|
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
|
let cfg = cfgspecs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
|
|
|
@ -147,7 +147,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
|
||||||
crate::callbacks::setup_callbacks();
|
crate::callbacks::setup_callbacks();
|
||||||
|
|
||||||
scoped_thread(cfg, || {
|
scoped_thread(cfg, || {
|
||||||
syntax::attr::with_globals(edition, || {
|
syntax::with_globals(edition, || {
|
||||||
ty::tls::GCX_PTR.set(&Lock::new(0), || {
|
ty::tls::GCX_PTR.set(&Lock::new(0), || {
|
||||||
if let Some(stderr) = stderr {
|
if let Some(stderr) = stderr {
|
||||||
io::set_panic(Some(box Sink(stderr.clone())));
|
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());
|
let with_pool = move |pool: &ThreadPool| pool.install(move || f());
|
||||||
|
|
||||||
syntax::attr::with_globals(edition, || {
|
syntax::with_globals(edition, || {
|
||||||
syntax::attr::GLOBALS.with(|syntax_globals| {
|
syntax::GLOBALS.with(|syntax_globals| {
|
||||||
rustc_span::GLOBALS.with(|rustc_span_globals| {
|
rustc_span::GLOBALS.with(|rustc_span_globals| {
|
||||||
// The main handler runs for each Rayon worker thread and sets up
|
// The main handler runs for each Rayon worker thread and sets up
|
||||||
// the thread local rustc uses. syntax_globals and rustc_span_globals are
|
// 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
|
// captured and set on the new threads. ty::tls::with_thread_locals sets up
|
||||||
// thread local callbacks from libsyntax
|
// thread local callbacks from libsyntax
|
||||||
let main_handler = move |thread: ThreadBuilder| {
|
let main_handler = move |thread: ThreadBuilder| {
|
||||||
syntax::attr::GLOBALS.set(syntax_globals, || {
|
syntax::GLOBALS.set(syntax_globals, || {
|
||||||
rustc_span::GLOBALS.set(rustc_span_globals, || {
|
rustc_span::GLOBALS.set(rustc_span_globals, || {
|
||||||
if let Some(stderr) = stderr {
|
if let Some(stderr) = stderr {
|
||||||
io::set_panic(Some(box Sink(stderr.clone())));
|
io::set_panic(Some(box Sink(stderr.clone())));
|
||||||
|
|
|
@ -18,7 +18,7 @@ use std::path::PathBuf;
|
||||||
use std::process::{self, Command, Stdio};
|
use std::process::{self, Command, Stdio};
|
||||||
use std::str;
|
use std::str;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr::with_globals;
|
use syntax::with_globals;
|
||||||
use tempfile::Builder as TempFileBuilder;
|
use tempfile::Builder as TempFileBuilder;
|
||||||
use testing;
|
use testing;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ pub mod util {
|
||||||
|
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
pub mod attr;
|
pub mod attr;
|
||||||
|
pub use attr::{with_default_globals, with_globals, GLOBALS};
|
||||||
pub mod entry;
|
pub mod entry;
|
||||||
pub mod expand;
|
pub mod expand;
|
||||||
pub mod mut_visit;
|
pub mod mut_visit;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue