Skip to content

Commit

Permalink
Auto merge of #64981 - tmandry:rollup-slfkhay, r=tmandry
Browse files Browse the repository at this point in the history
Rollup of 11 pull requests

Successful merges:

 - #64649 (Avoid ICE on return outside of fn with literal array)
 - #64722 (Make all alt builders produce parallel-enabled compilers)
 - #64801 (Avoid `chain()` in `find_constraint_paths_between_regions()`.)
 - #64805 (Still more `ObligationForest` improvements.)
 - #64840 (SelfProfiler API refactoring and part one of event review)
 - #64885 (use try_fold instead of try_for_each to reduce compile time)
 - #64942 (Fix clippy warnings)
 - #64952 (Update cargo.)
 - #64974 (Fix zebra-striping in generic dataflow visualization)
 - #64978 (Fully clear `HandlerInner` in `Handler::reset_err_count`)
 - #64979 (Update books)

Failed merges:

 - #64959 (syntax: improve parameter without type suggestions)

r? @ghost
  • Loading branch information
bors committed Oct 2, 2019
2 parents ff191b5 + 0878ca5 commit f2023ac
Show file tree
Hide file tree
Showing 40 changed files with 635 additions and 496 deletions.
15 changes: 7 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ dependencies = [

[[package]]
name = "cargo"
version = "0.40.0"
version = "0.41.0"
dependencies = [
"atty",
"bytesize",
Expand Down Expand Up @@ -600,7 +600,7 @@ checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"

[[package]]
name = "crates-io"
version = "0.28.0"
version = "0.29.0"
dependencies = [
"curl",
"failure",
Expand Down Expand Up @@ -730,25 +730,24 @@ dependencies = [

[[package]]
name = "curl"
version = "0.4.21"
version = "0.4.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a85f2f95f2bd277d316d1aa8a477687ab4a6942258c7db7c89c187534669979c"
checksum = "d08ad3cb89d076a36b0ce5749eec2c9964f70c0c58480ab6b75a91ec4fc206d8"
dependencies = [
"curl-sys",
"kernel32-sys",
"libc",
"openssl-probe",
"openssl-sys",
"schannel",
"socket2",
"winapi 0.2.8",
"winapi 0.3.6",
]

[[package]]
name = "curl-sys"
version = "0.4.18"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d91a0052d5b982887d8e829bee0faffc7218ea3c6ebd3d6c2c8f678a93c9a42"
checksum = "2e9a9a4e417722876332136a00cacf92c2ceb331fab4b52b6a1ad16c6cd79255"
dependencies = [
"cc",
"libc",
Expand Down
3 changes: 3 additions & 0 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
elif [ "$DEPLOY_ALT" != "" ]; then
if [ "$NO_PARALLEL_COMPILER" = "" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.parallel-compiler"
fi
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
fi
Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ impl DroplessArena {
// though it was supposed to give us `len`
return slice::from_raw_parts_mut(mem, i);
}
ptr::write(mem.offset(i as isize), value.unwrap());
ptr::write(mem.add(i), value.unwrap());
i += 1;
}
}
Expand Down
27 changes: 14 additions & 13 deletions src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,14 +1859,13 @@ pub trait Iterator {
Self: Sized, F: FnMut(Self::Item) -> bool
{
#[inline]
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut(T) -> LoopState<(), ()> {
move |x| {
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> LoopState<(), ()> {
move |(), x| {
if f(x) { LoopState::Continue(()) }
else { LoopState::Break(()) }
}
}

self.try_for_each(check(f)) == LoopState::Continue(())
self.try_fold((), check(f)) == LoopState::Continue(())
}

/// Tests if any element of the iterator matches a predicate.
Expand Down Expand Up @@ -1913,14 +1912,14 @@ pub trait Iterator {
F: FnMut(Self::Item) -> bool
{
#[inline]
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut(T) -> LoopState<(), ()> {
move |x| {
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> LoopState<(), ()> {
move |(), x| {
if f(x) { LoopState::Break(()) }
else { LoopState::Continue(()) }
}
}

self.try_for_each(check(f)) == LoopState::Break(())
self.try_fold((), check(f)) == LoopState::Break(())
}

/// Searches for an element of an iterator that satisfies a predicate.
Expand Down Expand Up @@ -1972,14 +1971,16 @@ pub trait Iterator {
P: FnMut(&Self::Item) -> bool,
{
#[inline]
fn check<T>(mut predicate: impl FnMut(&T) -> bool) -> impl FnMut(T) -> LoopState<(), T> {
move |x| {
fn check<T>(
mut predicate: impl FnMut(&T) -> bool
) -> impl FnMut((), T) -> LoopState<(), T> {
move |(), x| {
if predicate(&x) { LoopState::Break(x) }
else { LoopState::Continue(()) }
}
}

self.try_for_each(check(predicate)).break_value()
self.try_fold((), check(predicate)).break_value()
}

/// Applies function to the elements of iterator and returns
Expand All @@ -2004,14 +2005,14 @@ pub trait Iterator {
F: FnMut(Self::Item) -> Option<B>,
{
#[inline]
fn check<T, B>(mut f: impl FnMut(T) -> Option<B>) -> impl FnMut(T) -> LoopState<(), B> {
move |x| match f(x) {
fn check<T, B>(mut f: impl FnMut(T) -> Option<B>) -> impl FnMut((), T) -> LoopState<(), B> {
move |(), x| match f(x) {
Some(x) => LoopState::Break(x),
None => LoopState::Continue(()),
}
}

self.try_for_each(check(f)).break_value()
self.try_fold((), check(f)).break_value()
}

/// Searches for an element in an iterator, returning its index.
Expand Down
19 changes: 16 additions & 3 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ macro_rules! options {
pub const parse_list: Option<&str> = Some("a space-separated list of strings");
pub const parse_opt_list: Option<&str> = Some("a space-separated list of strings");
pub const parse_opt_comma_list: Option<&str> = Some("a comma-separated list of strings");
pub const parse_threads: Option<&str> = Some("a number");
pub const parse_uint: Option<&str> = Some("a number");
pub const parse_passes: Option<&str> =
Some("a space-separated list of passes, or `all`");
Expand Down Expand Up @@ -948,6 +949,14 @@ macro_rules! options {
}
}

fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
match v.and_then(|s| s.parse().ok()) {
Some(0) => { *slot = ::num_cpus::get(); true },
Some(i) => { *slot = i; true },
None => false
}
}

fn parse_uint(slot: &mut usize, v: Option<&str>) -> bool {
match v.and_then(|s| s.parse().ok()) {
Some(i) => { *slot = i; true },
Expand Down Expand Up @@ -1251,7 +1260,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"prints the LLVM optimization passes being run"),
ast_json: bool = (false, parse_bool, [UNTRACKED],
"print the AST as JSON and halt"),
threads: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
// We default to 1 here since we want to behave like
// a sequential compiler for now. This'll likely be adjusted
// in the future. Note that -Zthreads=0 is the way to get
// the num_cpus behavior.
threads: usize = (1, parse_threads, [UNTRACKED],
"use a thread pool with N threads"),
ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
"print the pre-expansion AST as JSON and halt"),
Expand Down Expand Up @@ -2146,14 +2159,14 @@ pub fn build_session_options_and_crate_config(
}
}

if debugging_opts.threads == Some(0) {
if debugging_opts.threads == 0 {
early_error(
error_format,
"value for threads must be a positive non-zero integer",
);
}

if debugging_opts.threads.unwrap_or(1) > 1 && debugging_opts.fuel.is_some() {
if debugging_opts.threads > 1 && debugging_opts.fuel.is_some() {
early_error(
error_format,
"optimization fuel is incompatible with multiple threads",
Expand Down
32 changes: 4 additions & 28 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use syntax::source_map;
use syntax::parse::{self, ParseSess};
use syntax::symbol::Symbol;
use syntax_pos::{MultiSpan, Span};
use crate::util::profiling::SelfProfiler;
use crate::util::profiling::{SelfProfiler, SelfProfilerRef};

use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple};
use rustc_data_structures::flock;
Expand Down Expand Up @@ -129,7 +129,7 @@ pub struct Session {
pub profile_channel: Lock<Option<mpsc::Sender<ProfileQueriesMsg>>>,

/// Used by `-Z self-profile`.
pub self_profiling: Option<Arc<SelfProfiler>>,
pub prof: SelfProfilerRef,

/// Some measurements that are being gathered during compilation.
pub perf_stats: PerfStats,
Expand Down Expand Up @@ -835,24 +835,6 @@ impl Session {
}
}

#[inline(never)]
#[cold]
fn profiler_active<F: FnOnce(&SelfProfiler) -> ()>(&self, f: F) {
match &self.self_profiling {
None => bug!("profiler_active() called but there was no profiler active"),
Some(profiler) => {
f(&profiler);
}
}
}

#[inline(always)]
pub fn profiler<F: FnOnce(&SelfProfiler) -> ()>(&self, f: F) {
if unlikely!(self.self_profiling.is_some()) {
self.profiler_active(f)
}
}

pub fn print_perf_stats(&self) {
println!(
"Total time spent computing symbol hashes: {}",
Expand Down Expand Up @@ -896,16 +878,10 @@ impl Session {
ret
}

/// Returns the number of query threads that should be used for this
/// compilation
pub fn threads_from_count(query_threads: Option<usize>) -> usize {
query_threads.unwrap_or(::num_cpus::get())
}

/// Returns the number of query threads that should be used for this
/// compilation
pub fn threads(&self) -> usize {
Self::threads_from_count(self.opts.debugging_opts.threads)
self.opts.debugging_opts.threads
}

/// Returns the number of codegen units that should be used for this
Expand Down Expand Up @@ -1257,7 +1233,7 @@ fn build_session_(
imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
cgu_reuse_tracker,
self_profiling: self_profiler,
prof: SelfProfilerRef::new(self_profiler),
profile_channel: Lock::new(None),
perf_stats: PerfStats {
symbol_hash_time: Lock::new(Duration::from_secs(0)),
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use crate::ty::CanonicalPolyFnSig;
use crate::util::common::ErrorReported;
use crate::util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap, ItemLocalSet};
use crate::util::nodemap::{FxHashMap, FxHashSet};
use crate::util::profiling::SelfProfilerRef;

use errors::DiagnosticBuilder;
use arena::SyncDroplessArena;
Expand Down Expand Up @@ -1030,6 +1031,8 @@ pub struct GlobalCtxt<'tcx> {

pub dep_graph: DepGraph,

pub prof: SelfProfilerRef,

/// Common objects.
pub common: Common<'tcx>,

Expand Down Expand Up @@ -1260,6 +1263,7 @@ impl<'tcx> TyCtxt<'tcx> {
arena: WorkerLocal::new(|_| Arena::default()),
interners,
dep_graph,
prof: s.prof.clone(),
common,
types: common_types,
lifetimes: common_lifetimes,
Expand Down
Loading

0 comments on commit f2023ac

Please sign in to comment.