Skip to content

Commit 4e3901d

Browse files
committed
Auto merge of #47678 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests - Successful merges: #47423, #47425, #47440, #47541, #47549, #47554, #47558, #47610, #47635, #47655, #47661, #47662, #47667, #47672 - Failed merges:
2 parents 3a39b2a + 9707b31 commit 4e3901d

File tree

38 files changed

+302
-103
lines changed

38 files changed

+302
-103
lines changed

src/Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/check.rs

+1
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ impl Step for Compiletest {
792792
flags.push("-g".to_string());
793793
}
794794
flags.push("-Zmiri -Zunstable-options".to_string());
795+
flags.push(build.config.cmd.rustc_args().join(" "));
795796

796797
if let Some(linker) = build.linker(target) {
797798
cmd.arg("--linker").arg(linker);

src/bootstrap/flags.rs

+17
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub enum Subcommand {
5454
Test {
5555
paths: Vec<PathBuf>,
5656
test_args: Vec<String>,
57+
rustc_args: Vec<String>,
5758
fail_fast: bool,
5859
},
5960
Bench {
@@ -150,6 +151,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
150151
"test" => {
151152
opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
152153
opts.optmulti("", "test-args", "extra arguments", "ARGS");
154+
opts.optmulti(
155+
"",
156+
"rustc-args",
157+
"extra options to pass the compiler when running tests",
158+
"ARGS",
159+
);
153160
},
154161
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
155162
"clean" => { opts.optflag("", "all", "clean all build artifacts"); },
@@ -283,6 +290,7 @@ Arguments:
283290
Subcommand::Test {
284291
paths,
285292
test_args: matches.opt_strs("test-args"),
293+
rustc_args: matches.opt_strs("rustc-args"),
286294
fail_fast: !matches.opt_present("no-fail-fast"),
287295
}
288296
}
@@ -362,6 +370,15 @@ impl Subcommand {
362370
}
363371
}
364372

373+
pub fn rustc_args(&self) -> Vec<&str> {
374+
match *self {
375+
Subcommand::Test { ref rustc_args, .. } => {
376+
rustc_args.iter().flat_map(|s| s.split_whitespace()).collect()
377+
}
378+
_ => Vec::new(),
379+
}
380+
}
381+
365382
pub fn fail_fast(&self) -> bool {
366383
match *self {
367384
Subcommand::Test { fail_fast, .. } => fail_fast,

src/liballoc_jemalloc/build.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,20 @@ fn main() {
2929
// for targets like emscripten, even if we don't use it.
3030
let target = env::var("TARGET").expect("TARGET was not set");
3131
let host = env::var("HOST").expect("HOST was not set");
32-
if target.contains("bitrig") || target.contains("cloudabi") || target.contains("emscripten") ||
33-
target.contains("fuchsia") || target.contains("msvc") || target.contains("openbsd") ||
34-
target.contains("redox") || target.contains("rumprun") || target.contains("wasm32") {
32+
if target.contains("bitrig") || target.contains("emscripten") || target.contains("fuchsia") ||
33+
target.contains("msvc") || target.contains("openbsd") || target.contains("redox") ||
34+
target.contains("rumprun") || target.contains("wasm32") {
3535
println!("cargo:rustc-cfg=dummy_jemalloc");
3636
return;
3737
}
3838

39+
// CloudABI ships with a copy of jemalloc that has been patched to
40+
// work well with sandboxing. Don't attempt to build our own copy,
41+
// as it won't build.
42+
if target.contains("cloudabi") {
43+
return;
44+
}
45+
3946
if target.contains("android") {
4047
println!("cargo:rustc-link-lib=gcc");
4148
} else if !target.contains("windows") && !target.contains("musl") {

src/librustc/ich/hcx.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use session::Session;
1919

2020
use std::cmp::Ord;
2121
use std::hash as std_hash;
22-
use std::cell::RefCell;
2322
use std::collections::HashMap;
23+
use std::cell::RefCell;
2424

2525
use syntax::ast;
2626

@@ -36,8 +36,10 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHashingContextProvi
3636
use rustc_data_structures::accumulate_vec::AccumulateVec;
3737
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
3838

39-
thread_local!(static IGNORED_ATTR_NAMES: RefCell<FxHashSet<Symbol>> =
40-
RefCell::new(FxHashSet()));
39+
pub fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
40+
debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
41+
ich::IGNORED_ATTRIBUTES.iter().map(|&s| Symbol::intern(s)).collect()
42+
}
4143

4244
/// This is the context state available during incr. comp. hashing. It contains
4345
/// enough information to transform DefIds and HirIds into stable DefPaths (i.e.
@@ -90,15 +92,6 @@ impl<'gcx> StableHashingContext<'gcx> {
9092
-> Self {
9193
let hash_spans_initial = !sess.opts.debugging_opts.incremental_ignore_spans;
9294

93-
debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
94-
IGNORED_ATTR_NAMES.with(|names| {
95-
let mut names = names.borrow_mut();
96-
if names.is_empty() {
97-
names.extend(ich::IGNORED_ATTRIBUTES.iter()
98-
.map(|&s| Symbol::intern(s)));
99-
}
100-
});
101-
10295
StableHashingContext {
10396
sess,
10497
body_resolver: BodyResolver(krate),
@@ -186,9 +179,7 @@ impl<'gcx> StableHashingContext<'gcx> {
186179

187180
#[inline]
188181
pub fn is_ignored_attr(&self, name: Symbol) -> bool {
189-
IGNORED_ATTR_NAMES.with(|names| {
190-
names.borrow().contains(&name)
191-
})
182+
self.sess.ignored_attr_names.contains(&name)
192183
}
193184

194185
pub fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self, f: F) {

src/librustc/ich/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
pub use self::fingerprint::Fingerprint;
1414
pub use self::caching_codemap_view::CachingCodemapView;
1515
pub use self::hcx::{StableHashingContext, NodeIdHashingMode,
16-
hash_stable_trait_impls};
16+
hash_stable_trait_impls, compute_ignored_attr_names};
1717
mod fingerprint;
1818
mod caching_codemap_view;
1919
mod hcx;

src/librustc/session/config.rs

+24-12
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ macro_rules! options {
778778
Some(::rustc_back::LinkerFlavor::one_of());
779779
pub const parse_optimization_fuel: Option<&'static str> =
780780
Some("crate=integer");
781+
pub const parse_unpretty: Option<&'static str> =
782+
Some("`string` or `string=string`");
781783
}
782784

783785
#[allow(dead_code)]
@@ -965,6 +967,17 @@ macro_rules! options {
965967
}
966968
}
967969
}
970+
971+
fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
972+
match v {
973+
None => false,
974+
Some(s) if s.split('=').count() <= 2 => {
975+
*slot = Some(s.to_string());
976+
true
977+
}
978+
_ => false,
979+
}
980+
}
968981
}
969982
) }
970983

@@ -1104,13 +1117,13 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
11041117
"write syntax and type analysis (in JSON format) information, in \
11051118
addition to normal output"),
11061119
flowgraph_print_loans: bool = (false, parse_bool, [UNTRACKED],
1107-
"include loan analysis data in --unpretty flowgraph output"),
1120+
"include loan analysis data in -Z unpretty flowgraph output"),
11081121
flowgraph_print_moves: bool = (false, parse_bool, [UNTRACKED],
1109-
"include move analysis data in --unpretty flowgraph output"),
1122+
"include move analysis data in -Z unpretty flowgraph output"),
11101123
flowgraph_print_assigns: bool = (false, parse_bool, [UNTRACKED],
1111-
"include assignment analysis data in --unpretty flowgraph output"),
1124+
"include assignment analysis data in -Z unpretty flowgraph output"),
11121125
flowgraph_print_all: bool = (false, parse_bool, [UNTRACKED],
1113-
"include all dataflow analysis data in --unpretty flowgraph output"),
1126+
"include all dataflow analysis data in -Z unpretty flowgraph output"),
11141127
print_region_graph: bool = (false, parse_bool, [UNTRACKED],
11151128
"prints region inference graph. \
11161129
Use with RUST_REGION_GRAPH=help for more info"),
@@ -1241,6 +1254,13 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12411254
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
12421255
"in dep-info output, omit targets for tracking dependencies of the dep-info files \
12431256
themselves"),
1257+
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
1258+
"Present the input source, unstable (and less-pretty) variants;
1259+
valid types are any of the types for `--pretty`, as well as:
1260+
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
1261+
`everybody_loops` (all function bodies replaced with `loop {}`),
1262+
`hir` (the HIR), `hir,identified`, or
1263+
`hir,typed` (HIR with types for each node)."),
12441264
}
12451265

12461266
pub fn default_lib_output() -> CrateType {
@@ -1514,14 +1534,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
15141534
`expanded` (crates expanded), or
15151535
`expanded,identified` (fully parenthesized, AST nodes with IDs).",
15161536
"TYPE"),
1517-
opt::opt("", "unpretty",
1518-
"Present the input source, unstable (and less-pretty) variants;
1519-
valid types are any of the types for `--pretty`, as well as:
1520-
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
1521-
`everybody_loops` (all function bodies replaced with `loop {}`),
1522-
`hir` (the HIR), `hir,identified`, or
1523-
`hir,typed` (HIR with types for each node).",
1524-
"TYPE"),
15251537
]);
15261538
opts
15271539
}

src/librustc/session/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub use self::code_stats::{SizeKind, TypeSizeInfo, VariantInfo};
1414
use hir::def_id::CrateNum;
1515
use ich::Fingerprint;
1616

17+
use ich;
1718
use lint;
1819
use middle::allocator::AllocatorKind;
1920
use middle::dependency_format;
@@ -28,6 +29,7 @@ use errors::{self, DiagnosticBuilder, DiagnosticId};
2829
use errors::emitter::{Emitter, EmitterWriter};
2930
use syntax::json::JsonEmitter;
3031
use syntax::feature_gate;
32+
use syntax::symbol::Symbol;
3133
use syntax::parse;
3234
use syntax::parse::ParseSess;
3335
use syntax::{ast, codemap};
@@ -112,6 +114,9 @@ pub struct Session {
112114

113115
incr_comp_session: RefCell<IncrCompSession>,
114116

117+
/// A cache of attributes ignored by StableHashingContext
118+
pub ignored_attr_names: FxHashSet<Symbol>,
119+
115120
/// Some measurements that are being gathered during compilation.
116121
pub perf_stats: PerfStats,
117122

@@ -975,6 +980,7 @@ pub fn build_session_(sopts: config::Options,
975980
injected_panic_runtime: Cell::new(None),
976981
imported_macro_spans: RefCell::new(HashMap::new()),
977982
incr_comp_session: RefCell::new(IncrCompSession::NotInitialized),
983+
ignored_attr_names: ich::compute_ignored_attr_names(),
978984
perf_stats: PerfStats {
979985
svh_time: Cell::new(Duration::from_secs(0)),
980986
incr_comp_hashes_time: Cell::new(Duration::from_secs(0)),

src/librustc_driver/driver.rs

+9-21
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ use std::iter;
5151
use std::path::{Path, PathBuf};
5252
use std::rc::Rc;
5353
use std::sync::mpsc;
54-
use syntax::{ast, diagnostics, visit};
55-
use syntax::attr;
54+
use syntax::{self, ast, attr, diagnostics, visit};
5655
use syntax::ext::base::ExtCtxt;
5756
use syntax::fold::Folder;
5857
use syntax::parse::{self, PResult};
5958
use syntax::util::node_count::NodeCounter;
6059
use syntax_pos::FileName;
61-
use syntax;
6260
use syntax_ext;
6361

6462
use derive_registrar;
@@ -275,10 +273,6 @@ pub fn compile_input(trans: Box<TransCrate>,
275273
Ok(())
276274
}
277275

278-
fn keep_hygiene_data(sess: &Session) -> bool {
279-
sess.opts.debugging_opts.keep_hygiene_data
280-
}
281-
282276
pub fn source_name(input: &Input) -> FileName {
283277
match *input {
284278
Input::File(ref ifile) => ifile.clone().into(),
@@ -900,7 +894,7 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
900894
|| lint::check_ast_crate(sess, &krate));
901895

902896
// Discard hygiene data, which isn't required after lowering to HIR.
903-
if !keep_hygiene_data(sess) {
897+
if !sess.opts.debugging_opts.keep_hygiene_data {
904898
syntax::ext::hygiene::clear_markings();
905899
}
906900

@@ -952,18 +946,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate,
952946
mpsc::Receiver<Box<Any + Send>>,
953947
CompileResult) -> R
954948
{
955-
macro_rules! try_with_f {
956-
($e: expr, ($($t:tt)*)) => {
957-
match $e {
958-
Ok(x) => x,
959-
Err(x) => {
960-
f($($t)*, Err(x));
961-
return Err(x);
962-
}
963-
}
964-
}
965-
}
966-
967949
let time_passes = sess.time_passes();
968950

969951
let query_result_on_disk_cache = time(time_passes,
@@ -1024,7 +1006,13 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate,
10241006
|| stability::check_unstable_api_usage(tcx));
10251007

10261008
// passes are timed inside typeck
1027-
try_with_f!(typeck::check_crate(tcx), (tcx, analysis, rx));
1009+
match typeck::check_crate(tcx) {
1010+
Ok(x) => x,
1011+
Err(x) => {
1012+
f(tcx, analysis, rx, Err(x));
1013+
return Err(x);
1014+
}
1015+
}
10281016

10291017
time(time_passes,
10301018
"const checking",

0 commit comments

Comments
 (0)