Skip to content

Commit 6c53749

Browse files
committed
Auto merge of #49558 - Zoxc:sync-misc, r=michaelwoerister
Even more thread-safety changes r? @michaelwoerister
2 parents 9afed64 + 006f9b2 commit 6c53749

40 files changed

+425
-285
lines changed

src/librustc/dep_graph/dep_node.rs

+1
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ define_dep_nodes!( <'tcx>
632632
[input] MaybeUnusedTraitImport(DefId),
633633
[input] MaybeUnusedExternCrates,
634634
[eval_always] StabilityIndex,
635+
[eval_always] AllTraits,
635636
[input] AllCrateNums,
636637
[] ExportedSymbols(CrateNum),
637638
[eval_always] CollectAndPartitionTranslationItems,

src/librustc/infer/canonical.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ use rustc_data_structures::indexed_vec::Idx;
3636
use serialize::UseSpecializedDecodable;
3737
use std::fmt::Debug;
3838
use std::ops::Index;
39+
use std::sync::atomic::Ordering;
3940
use syntax::codemap::Span;
4041
use traits::{Obligation, ObligationCause, PredicateObligation};
4142
use ty::{self, CanonicalVar, Lift, Region, Slice, Ty, TyCtxt, TypeFlags};
4243
use ty::subst::{Kind, UnpackedKind};
4344
use ty::fold::{TypeFoldable, TypeFolder};
4445
use util::captures::Captures;
45-
use util::common::CellUsizeExt;
4646

4747
use rustc_data_structures::indexed_vec::IndexVec;
4848
use rustc_data_structures::fx::FxHashMap;
@@ -473,7 +473,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
473473
where
474474
V: Canonicalize<'gcx, 'tcx>,
475475
{
476-
self.tcx.sess.perf_stats.queries_canonicalized.increment();
476+
self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
477477

478478
Canonicalizer::canonicalize(
479479
value,

src/librustc/middle/dead.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
408408
}
409409

410410
// Seed entry point
411-
if let Some((id, _)) = *tcx.sess.entry_fn.borrow() {
411+
if let Some((id, _, _)) = *tcx.sess.entry_fn.borrow() {
412412
worklist.push(id);
413413
}
414414

src/librustc/middle/dependency_format.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ pub enum Linkage {
9494

9595
pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
9696
let sess = &tcx.sess;
97-
let mut fmts = sess.dependency_formats.borrow_mut();
97+
let mut fmts = FxHashMap();
9898
for &ty in sess.crate_types.borrow().iter() {
9999
let linkage = calculate_type(tcx, ty);
100100
verify_ok(tcx, &linkage);
101101
fmts.insert(ty, linkage);
102102
}
103103
sess.abort_if_errors();
104+
sess.dependency_formats.set(fmts);
104105
}
105106

106107
fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -222,7 +223,7 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
222223
//
223224
// Things like allocators and panic runtimes may not have been activated
224225
// quite yet, so do so here.
225-
activate_injected_dep(sess.injected_panic_runtime.get(), &mut ret,
226+
activate_injected_dep(*sess.injected_panic_runtime.get(), &mut ret,
226227
&|cnum| tcx.is_panic_runtime(cnum));
227228
activate_injected_allocator(sess, &mut ret);
228229

@@ -301,7 +302,7 @@ fn attempt_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<DependencyLis
301302
// Our allocator/panic runtime may not have been linked above if it wasn't
302303
// explicitly linked, which is the case for any injected dependency. Handle
303304
// that here and activate them.
304-
activate_injected_dep(sess.injected_panic_runtime.get(), &mut ret,
305+
activate_injected_dep(*sess.injected_panic_runtime.get(), &mut ret,
305306
&|cnum| tcx.is_panic_runtime(cnum));
306307
activate_injected_allocator(sess, &mut ret);
307308

src/librustc/middle/entry.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ pub fn find_entry_point(session: &Session,
6363
});
6464
if !any_exe {
6565
// No need to find a main function
66+
session.entry_fn.set(None);
6667
return
6768
}
6869

6970
// If the user wants no main function at all, then stop here.
7071
if attr::contains_name(&hir_map.krate().attrs, "no_main") {
71-
session.entry_type.set(Some(config::EntryNone));
72+
session.entry_fn.set(None);
7273
return
7374
}
7475

@@ -153,17 +154,15 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
153154
}
154155

155156
fn configure_main(this: &mut EntryContext, crate_name: &str) {
156-
if this.start_fn.is_some() {
157-
*this.session.entry_fn.borrow_mut() = this.start_fn;
158-
this.session.entry_type.set(Some(config::EntryStart));
159-
} else if this.attr_main_fn.is_some() {
160-
*this.session.entry_fn.borrow_mut() = this.attr_main_fn;
161-
this.session.entry_type.set(Some(config::EntryMain));
162-
} else if this.main_fn.is_some() {
163-
*this.session.entry_fn.borrow_mut() = this.main_fn;
164-
this.session.entry_type.set(Some(config::EntryMain));
157+
if let Some((node_id, span)) = this.start_fn {
158+
this.session.entry_fn.set(Some((node_id, span, config::EntryStart)));
159+
} else if let Some((node_id, span)) = this.attr_main_fn {
160+
this.session.entry_fn.set(Some((node_id, span, config::EntryMain)));
161+
} else if let Some((node_id, span)) = this.main_fn {
162+
this.session.entry_fn.set(Some((node_id, span, config::EntryMain)));
165163
} else {
166164
// No main function
165+
this.session.entry_fn.set(None);
167166
let mut err = struct_err!(this.session, E0601,
168167
"`main` function not found in crate `{}`", crate_name);
169168
if !this.non_main_fns.is_empty() {

src/librustc/middle/recursion_limit.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
use session::Session;
1919
use syntax::ast;
2020

21-
use std::cell::Cell;
21+
use rustc_data_structures::sync::Once;
2222

2323
pub fn update_limits(sess: &Session, krate: &ast::Crate) {
2424
update_limit(sess, krate, &sess.recursion_limit, "recursion_limit",
25-
"recursion limit");
25+
"recursion limit", 64);
2626
update_limit(sess, krate, &sess.type_length_limit, "type_length_limit",
27-
"type length limit");
27+
"type length limit", 1048576);
2828
}
2929

30-
fn update_limit(sess: &Session, krate: &ast::Crate, limit: &Cell<usize>,
31-
name: &str, description: &str) {
30+
fn update_limit(sess: &Session, krate: &ast::Crate, limit: &Once<usize>,
31+
name: &str, description: &str, default: usize) {
3232
for attr in &krate.attrs {
3333
if !attr.check_name(name) {
3434
continue;
@@ -45,4 +45,5 @@ fn update_limit(sess: &Session, krate: &ast::Crate, limit: &Cell<usize>,
4545
"malformed {} attribute, expected #![{}=\"N\"]",
4646
description, name);
4747
}
48+
limit.set(default);
4849
}

src/librustc/session/config.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,11 @@ impl Options {
614614

615615
// The type of entry function, so
616616
// users can have their own entry
617-
// functions that don't start a
618-
// scheduler
617+
// functions
619618
#[derive(Copy, Clone, PartialEq)]
620619
pub enum EntryFnType {
621620
EntryMain,
622621
EntryStart,
623-
EntryNone,
624622
}
625623

626624
#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug)]
@@ -1861,6 +1859,13 @@ pub fn build_session_options_and_crate_config(
18611859
);
18621860
}
18631861

1862+
if debugging_opts.query_threads.unwrap_or(1) > 1 && debugging_opts.fuel.is_some() {
1863+
early_error(
1864+
error_format,
1865+
"Optimization fuel is incompatible with multiple query threads",
1866+
);
1867+
}
1868+
18641869
if codegen_units == Some(0) {
18651870
early_error(
18661871
error_format,

0 commit comments

Comments
 (0)