-use log::info;
use rustc_ast::ast::{AttrVec, BlockCheckMode};
use rustc_ast::mut_visit::{visit_clobber, MutVisitor, *};
use rustc_ast::ptr::P;
#[cfg(parallel_compiler)]
use rustc_data_structures::jobserver;
use rustc_data_structures::stable_hasher::StableHasher;
-use rustc_data_structures::sync::{Lock, Lrc};
+use rustc_data_structures::sync::Lrc;
use rustc_errors::registry::Registry;
use rustc_metadata::dynamic_lib::DynamicLibrary;
-use rustc_middle::ty;
use rustc_resolve::{self, Resolver};
use rustc_session as session;
use rustc_session::config::{self, CrateType};
use std::sync::{Arc, Mutex, Once};
#[cfg(not(parallel_compiler))]
use std::{panic, thread};
+use tracing::info;
/// Adds `target_feature = "..."` cfgs for a variety of platform
/// specific features (SSE, NEON etc.).
crate::callbacks::setup_callbacks();
let main_handler = move || {
- rustc_ast::with_session_globals(edition, || {
- ty::tls::GCX_PTR.set(&Lock::new(0), || {
- if let Some(stderr) = stderr {
- io::set_panic(Some(box Sink(stderr.clone())));
- }
- f()
- })
+ rustc_span::with_session_globals(edition, || {
+ if let Some(stderr) = stderr {
+ io::set_panic(Some(box Sink(stderr.clone())));
+ }
+ f()
})
};
stderr: &Option<Arc<Mutex<Vec<u8>>>>,
f: F,
) -> R {
+ use rustc_middle::ty;
crate::callbacks::setup_callbacks();
let mut config = rayon::ThreadPoolBuilder::new()
let with_pool = move |pool: &rayon::ThreadPool| pool.install(move || f());
- rustc_ast::with_session_globals(edition, || {
- rustc_ast::SESSION_GLOBALS.with(|ast_session_globals| {
- rustc_span::SESSION_GLOBALS.with(|span_session_globals| {
- // The main handler runs for each Rayon worker thread and sets
- // up the thread local rustc uses. ast_session_globals and
- // span_session_globals are captured and set on the new
- // threads. ty::tls::with_thread_locals sets up thread local
- // callbacks from librustc_ast.
- let main_handler = move |thread: rayon::ThreadBuilder| {
- rustc_ast::SESSION_GLOBALS.set(ast_session_globals, || {
- rustc_span::SESSION_GLOBALS.set(span_session_globals, || {
- ty::tls::GCX_PTR.set(&Lock::new(0), || {
- if let Some(stderr) = stderr {
- io::set_panic(Some(box Sink(stderr.clone())));
- }
- thread.run()
- })
- })
- })
- };
+ rustc_span::with_session_globals(edition, || {
+ rustc_span::SESSION_GLOBALS.with(|session_globals| {
+ // The main handler runs for each Rayon worker thread and sets up
+ // the thread local rustc uses. `session_globals` is captured and set
+ // on the new threads.
+ let main_handler = move |thread: rayon::ThreadBuilder| {
+ rustc_span::SESSION_GLOBALS.set(session_globals, || {
+ if let Some(stderr) = stderr {
+ io::set_panic(Some(box Sink(stderr.clone())));
+ }
+ thread.run()
+ })
+ };
- config.build_scoped(main_handler, with_pool).unwrap()
- })
+ config.build_scoped(main_handler, with_pool).unwrap()
})
})
}
CrateDisambiguator::from(hasher.finish::<Fingerprint>())
}
-pub(crate) fn check_attr_crate_type(attrs: &[ast::Attribute], lint_buffer: &mut LintBuffer) {
+pub(crate) fn check_attr_crate_type(
+ sess: &Session,
+ attrs: &[ast::Attribute],
+ lint_buffer: &mut LintBuffer,
+) {
// Unconditionally collect crate types from attributes to make them used
for a in attrs.iter() {
- if a.check_name(sym::crate_type) {
+ if sess.check_name(a, sym::crate_type) {
if let Some(n) = a.value_str() {
if categorize_crate_type(n).is_some() {
return;
let attr_types: Vec<CrateType> = attrs
.iter()
.filter_map(|a| {
- if a.check_name(sym::crate_type) {
+ if session.check_name(a, sym::crate_type) {
match a.value_str() {
Some(s) => categorize_crate_type(s),
_ => None,
.opts
.crate_name
.clone()
- .or_else(|| rustc_attr::find_crate_name(attrs).map(|n| n.to_string()))
+ .or_else(|| rustc_attr::find_crate_name(&sess, attrs).map(|n| n.to_string()))
.unwrap_or_else(|| input.filestem().to_owned());
OutputFilenames::new(