Skip to content

Commit f2023ac

Browse files
committed
Auto merge of #64981 - tmandry:rollup-slfkhay, r=tmandry
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
2 parents ff191b5 + 0878ca5 commit f2023ac

File tree

40 files changed

+635
-496
lines changed

40 files changed

+635
-496
lines changed

Cargo.lock

+7-8
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ dependencies = [
265265

266266
[[package]]
267267
name = "cargo"
268-
version = "0.40.0"
268+
version = "0.41.0"
269269
dependencies = [
270270
"atty",
271271
"bytesize",
@@ -600,7 +600,7 @@ checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
600600

601601
[[package]]
602602
name = "crates-io"
603-
version = "0.28.0"
603+
version = "0.29.0"
604604
dependencies = [
605605
"curl",
606606
"failure",
@@ -730,25 +730,24 @@ dependencies = [
730730

731731
[[package]]
732732
name = "curl"
733-
version = "0.4.21"
733+
version = "0.4.24"
734734
source = "registry+https://github.com/rust-lang/crates.io-index"
735-
checksum = "a85f2f95f2bd277d316d1aa8a477687ab4a6942258c7db7c89c187534669979c"
735+
checksum = "d08ad3cb89d076a36b0ce5749eec2c9964f70c0c58480ab6b75a91ec4fc206d8"
736736
dependencies = [
737737
"curl-sys",
738-
"kernel32-sys",
739738
"libc",
740739
"openssl-probe",
741740
"openssl-sys",
742741
"schannel",
743742
"socket2",
744-
"winapi 0.2.8",
743+
"winapi 0.3.6",
745744
]
746745

747746
[[package]]
748747
name = "curl-sys"
749-
version = "0.4.18"
748+
version = "0.4.22"
750749
source = "registry+https://github.com/rust-lang/crates.io-index"
751-
checksum = "9d91a0052d5b982887d8e829bee0faffc7218ea3c6ebd3d6c2c8f678a93c9a42"
750+
checksum = "2e9a9a4e417722876332136a00cacf92c2ceb331fab4b52b6a1ad16c6cd79255"
752751
dependencies = [
753752
"cc",
754753
"libc",

src/ci/run.sh

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
5555
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
5656
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
5757
elif [ "$DEPLOY_ALT" != "" ]; then
58+
if [ "$NO_PARALLEL_COMPILER" = "" ]; then
59+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.parallel-compiler"
60+
fi
5861
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
5962
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
6063
fi

src/doc/reference

src/libarena/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ impl DroplessArena {
500500
// though it was supposed to give us `len`
501501
return slice::from_raw_parts_mut(mem, i);
502502
}
503-
ptr::write(mem.offset(i as isize), value.unwrap());
503+
ptr::write(mem.add(i), value.unwrap());
504504
i += 1;
505505
}
506506
}

src/libcore/iter/traits/iterator.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -1859,14 +1859,13 @@ pub trait Iterator {
18591859
Self: Sized, F: FnMut(Self::Item) -> bool
18601860
{
18611861
#[inline]
1862-
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut(T) -> LoopState<(), ()> {
1863-
move |x| {
1862+
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> LoopState<(), ()> {
1863+
move |(), x| {
18641864
if f(x) { LoopState::Continue(()) }
18651865
else { LoopState::Break(()) }
18661866
}
18671867
}
1868-
1869-
self.try_for_each(check(f)) == LoopState::Continue(())
1868+
self.try_fold((), check(f)) == LoopState::Continue(())
18701869
}
18711870

18721871
/// Tests if any element of the iterator matches a predicate.
@@ -1913,14 +1912,14 @@ pub trait Iterator {
19131912
F: FnMut(Self::Item) -> bool
19141913
{
19151914
#[inline]
1916-
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut(T) -> LoopState<(), ()> {
1917-
move |x| {
1915+
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> LoopState<(), ()> {
1916+
move |(), x| {
19181917
if f(x) { LoopState::Break(()) }
19191918
else { LoopState::Continue(()) }
19201919
}
19211920
}
19221921

1923-
self.try_for_each(check(f)) == LoopState::Break(())
1922+
self.try_fold((), check(f)) == LoopState::Break(())
19241923
}
19251924

19261925
/// Searches for an element of an iterator that satisfies a predicate.
@@ -1972,14 +1971,16 @@ pub trait Iterator {
19721971
P: FnMut(&Self::Item) -> bool,
19731972
{
19741973
#[inline]
1975-
fn check<T>(mut predicate: impl FnMut(&T) -> bool) -> impl FnMut(T) -> LoopState<(), T> {
1976-
move |x| {
1974+
fn check<T>(
1975+
mut predicate: impl FnMut(&T) -> bool
1976+
) -> impl FnMut((), T) -> LoopState<(), T> {
1977+
move |(), x| {
19771978
if predicate(&x) { LoopState::Break(x) }
19781979
else { LoopState::Continue(()) }
19791980
}
19801981
}
19811982

1982-
self.try_for_each(check(predicate)).break_value()
1983+
self.try_fold((), check(predicate)).break_value()
19831984
}
19841985

19851986
/// Applies function to the elements of iterator and returns
@@ -2004,14 +2005,14 @@ pub trait Iterator {
20042005
F: FnMut(Self::Item) -> Option<B>,
20052006
{
20062007
#[inline]
2007-
fn check<T, B>(mut f: impl FnMut(T) -> Option<B>) -> impl FnMut(T) -> LoopState<(), B> {
2008-
move |x| match f(x) {
2008+
fn check<T, B>(mut f: impl FnMut(T) -> Option<B>) -> impl FnMut((), T) -> LoopState<(), B> {
2009+
move |(), x| match f(x) {
20092010
Some(x) => LoopState::Break(x),
20102011
None => LoopState::Continue(()),
20112012
}
20122013
}
20132014

2014-
self.try_for_each(check(f)).break_value()
2015+
self.try_fold((), check(f)).break_value()
20152016
}
20162017

20172018
/// Searches for an element in an iterator, returning its index.

src/librustc/session/config.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ macro_rules! options {
805805
pub const parse_list: Option<&str> = Some("a space-separated list of strings");
806806
pub const parse_opt_list: Option<&str> = Some("a space-separated list of strings");
807807
pub const parse_opt_comma_list: Option<&str> = Some("a comma-separated list of strings");
808+
pub const parse_threads: Option<&str> = Some("a number");
808809
pub const parse_uint: Option<&str> = Some("a number");
809810
pub const parse_passes: Option<&str> =
810811
Some("a space-separated list of passes, or `all`");
@@ -948,6 +949,14 @@ macro_rules! options {
948949
}
949950
}
950951

952+
fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
953+
match v.and_then(|s| s.parse().ok()) {
954+
Some(0) => { *slot = ::num_cpus::get(); true },
955+
Some(i) => { *slot = i; true },
956+
None => false
957+
}
958+
}
959+
951960
fn parse_uint(slot: &mut usize, v: Option<&str>) -> bool {
952961
match v.and_then(|s| s.parse().ok()) {
953962
Some(i) => { *slot = i; true },
@@ -1251,7 +1260,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12511260
"prints the LLVM optimization passes being run"),
12521261
ast_json: bool = (false, parse_bool, [UNTRACKED],
12531262
"print the AST as JSON and halt"),
1254-
threads: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
1263+
// We default to 1 here since we want to behave like
1264+
// a sequential compiler for now. This'll likely be adjusted
1265+
// in the future. Note that -Zthreads=0 is the way to get
1266+
// the num_cpus behavior.
1267+
threads: usize = (1, parse_threads, [UNTRACKED],
12551268
"use a thread pool with N threads"),
12561269
ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
12571270
"print the pre-expansion AST as JSON and halt"),
@@ -2146,14 +2159,14 @@ pub fn build_session_options_and_crate_config(
21462159
}
21472160
}
21482161

2149-
if debugging_opts.threads == Some(0) {
2162+
if debugging_opts.threads == 0 {
21502163
early_error(
21512164
error_format,
21522165
"value for threads must be a positive non-zero integer",
21532166
);
21542167
}
21552168

2156-
if debugging_opts.threads.unwrap_or(1) > 1 && debugging_opts.fuel.is_some() {
2169+
if debugging_opts.threads > 1 && debugging_opts.fuel.is_some() {
21572170
early_error(
21582171
error_format,
21592172
"optimization fuel is incompatible with multiple threads",

src/librustc/session/mod.rs

+4-28
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use syntax::source_map;
3232
use syntax::parse::{self, ParseSess};
3333
use syntax::symbol::Symbol;
3434
use syntax_pos::{MultiSpan, Span};
35-
use crate::util::profiling::SelfProfiler;
35+
use crate::util::profiling::{SelfProfiler, SelfProfilerRef};
3636

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

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

134134
/// Some measurements that are being gathered during compilation.
135135
pub perf_stats: PerfStats,
@@ -835,24 +835,6 @@ impl Session {
835835
}
836836
}
837837

838-
#[inline(never)]
839-
#[cold]
840-
fn profiler_active<F: FnOnce(&SelfProfiler) -> ()>(&self, f: F) {
841-
match &self.self_profiling {
842-
None => bug!("profiler_active() called but there was no profiler active"),
843-
Some(profiler) => {
844-
f(&profiler);
845-
}
846-
}
847-
}
848-
849-
#[inline(always)]
850-
pub fn profiler<F: FnOnce(&SelfProfiler) -> ()>(&self, f: F) {
851-
if unlikely!(self.self_profiling.is_some()) {
852-
self.profiler_active(f)
853-
}
854-
}
855-
856838
pub fn print_perf_stats(&self) {
857839
println!(
858840
"Total time spent computing symbol hashes: {}",
@@ -896,16 +878,10 @@ impl Session {
896878
ret
897879
}
898880

899-
/// Returns the number of query threads that should be used for this
900-
/// compilation
901-
pub fn threads_from_count(query_threads: Option<usize>) -> usize {
902-
query_threads.unwrap_or(::num_cpus::get())
903-
}
904-
905881
/// Returns the number of query threads that should be used for this
906882
/// compilation
907883
pub fn threads(&self) -> usize {
908-
Self::threads_from_count(self.opts.debugging_opts.threads)
884+
self.opts.debugging_opts.threads
909885
}
910886

911887
/// Returns the number of codegen units that should be used for this
@@ -1257,7 +1233,7 @@ fn build_session_(
12571233
imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
12581234
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
12591235
cgu_reuse_tracker,
1260-
self_profiling: self_profiler,
1236+
prof: SelfProfilerRef::new(self_profiler),
12611237
profile_channel: Lock::new(None),
12621238
perf_stats: PerfStats {
12631239
symbol_hash_time: Lock::new(Duration::from_secs(0)),

src/librustc/ty/context.rs

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use crate::ty::CanonicalPolyFnSig;
4545
use crate::util::common::ErrorReported;
4646
use crate::util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap, ItemLocalSet};
4747
use crate::util::nodemap::{FxHashMap, FxHashSet};
48+
use crate::util::profiling::SelfProfilerRef;
4849

4950
use errors::DiagnosticBuilder;
5051
use arena::SyncDroplessArena;
@@ -1030,6 +1031,8 @@ pub struct GlobalCtxt<'tcx> {
10301031

10311032
pub dep_graph: DepGraph,
10321033

1034+
pub prof: SelfProfilerRef,
1035+
10331036
/// Common objects.
10341037
pub common: Common<'tcx>,
10351038

@@ -1260,6 +1263,7 @@ impl<'tcx> TyCtxt<'tcx> {
12601263
arena: WorkerLocal::new(|_| Arena::default()),
12611264
interners,
12621265
dep_graph,
1266+
prof: s.prof.clone(),
12631267
common,
12641268
types: common_types,
12651269
lifetimes: common_lifetimes,

0 commit comments

Comments
 (0)