From 1a370109ec176fa33a9cac2fe143b43c56ebcfd9 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 24 Jul 2019 11:44:14 +0300 Subject: [PATCH] Fix `cfg(parallel_compiler)` mode Fix rebase --- src/bootstrap/bin/rustc.rs | 2 ++ src/libcore/array.rs | 4 +-- src/librustc/ty/query/job.rs | 48 ++++++++++---------------------- src/librustc_interface/passes.rs | 1 - src/librustc_interface/util.rs | 2 -- 5 files changed, 19 insertions(+), 38 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 2e9044a8150cd..23f81c2c87692 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -127,6 +127,8 @@ fn main() { if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none() { + // When extending this list, search for `NO-RUSTC-WRAPPER` and add the new lints + // there as well, some code doesn't go through this `rustc` wrapper. cmd.arg("-Dwarnings"); cmd.arg("-Drust_2018_idioms"); cmd.arg("-Dunused_lifetimes"); diff --git a/src/libcore/array.rs b/src/libcore/array.rs index 6023bc21e7496..517893a1967dc 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -217,7 +217,7 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, A, B, const N: usize> PartialEq<[B; N]> for [A; N] +impl PartialEq<[B; N]> for [A; N] where A: PartialEq, [A; N]: LengthAtMost32, @@ -234,7 +234,7 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, A, B, const N: usize> PartialEq<[B]> for [A; N] +impl PartialEq<[B]> for [A; N] where A: PartialEq, [A; N]: LengthAtMost32, diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index c4e798f7461a6..a25560ff762a1 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -1,35 +1,25 @@ -#![allow(unused_imports)] // `cfg(parallel_compiler)` - -use std::mem; -use std::process; -use std::{fmt, ptr}; +use crate::ty::context::TyCtxt; +use crate::ty::query::plumbing::CycleError; +use crate::ty::query::Query; +use crate::ty::tls; -use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::sync::{Lock, LockGuard, Lrc, Weak}; -use rustc_data_structures::OnDrop; -use rustc_data_structures::jobserver; +use rustc_data_structures::sync::Lrc; use syntax_pos::Span; -use crate::ty::tls; -use crate::ty::query::Query; -use crate::ty::query::plumbing::CycleError; #[cfg(not(parallel_compiler))] -use crate::ty::query::{ - plumbing::TryGetJob, - config::QueryDescription, -}; -use crate::ty::context::TyCtxt; +use std::ptr; #[cfg(parallel_compiler)] use { - rustc_rayon_core as rayon_core, parking_lot::{Mutex, Condvar}, - std::sync::atomic::Ordering, - std::thread, - std::iter, - std::iter::FromIterator, + rustc_data_structures::{jobserver, OnDrop}, + rustc_data_structures::fx::FxHashSet, + rustc_data_structures::stable_hasher::{StableHasher, HashStable}, + rustc_data_structures::sync::Lock, + rustc_rayon_core as rayon_core, syntax_pos::DUMMY_SP, - rustc_data_structures::stable_hasher::{StableHasherResult, StableHasher, HashStable}, + std::{mem, process, thread}, + std::iter::FromIterator, }; /// Indicates the state of a query for a given key in a query map. @@ -81,7 +71,7 @@ impl<'tcx> QueryJob<'tcx> { span: Span, ) -> Result<(), CycleError<'tcx>> { tls::with_related_context(tcx, move |icx| { - let mut waiter = Lrc::new(QueryWaiter { + let waiter = Lrc::new(QueryWaiter { query: icx.query.clone(), span, cycle: Lock::new(None), @@ -432,7 +422,7 @@ fn remove_cycle<'tcx>( let usage = usage.as_ref().map(|(span, query)| (*span, query.info.query.clone())); // Create the cycle error - let mut error = CycleError { + let error = CycleError { usage, cycle: stack.iter().map(|&(s, ref q)| QueryInfo { span: s, @@ -464,9 +454,6 @@ fn remove_cycle<'tcx>( /// Must only be called when a deadlock is about to happen. #[cfg(parallel_compiler)] pub unsafe fn handle_deadlock() { - use syntax; - use syntax_pos; - let registry = rayon_core::Registry::current(); let gcx_ptr = tls::GCX_PTR.with(|gcx_ptr| { @@ -474,11 +461,6 @@ pub unsafe fn handle_deadlock() { }); let gcx_ptr = &*gcx_ptr; - let syntax_globals = syntax::GLOBALS.with(|syntax_globals| { - syntax_globals as *const _ - }); - let syntax_globals = &*syntax_globals; - let syntax_pos_globals = syntax_pos::GLOBALS.with(|syntax_pos_globals| { syntax_pos_globals as *const _ }); diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index ac36ad7e30b09..8dd2595967fd7 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -17,7 +17,6 @@ use rustc::util::common::{time, ErrorReported}; use rustc::session::Session; use rustc::session::config::{self, CrateType, Input, OutputFilenames, OutputType}; use rustc::session::search_paths::PathKind; -use rustc_allocator as allocator; use rustc_ast_borrowck as borrowck; use rustc_codegen_ssa::back::link::emit_metadata; use rustc_codegen_utils::codegen_backend::CodegenBackend; diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 6ae5e94b11af3..f007a0cf2abee 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -203,8 +203,6 @@ pub fn spawn_thread_pool R + Send, R: Send>( f: F, ) -> R { use rayon::{ThreadPool, ThreadPoolBuilder}; - use syntax; - use syntax_pos; let gcx_ptr = &Lock::new(0);