Skip to content

Commit

Permalink
Auto merge of #47678 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

- Successful merges: #47423, #47425, #47440, #47541, #47549, #47554, #47558, #47610, #47635, #47655, #47661, #47662, #47667, #47672
- Failed merges:
  • Loading branch information
bors committed Jan 23, 2018
2 parents 3a39b2a + 9707b31 commit 4e3901d
Show file tree
Hide file tree
Showing 38 changed files with 302 additions and 103 deletions.
6 changes: 3 additions & 3 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ impl Step for Compiletest {
flags.push("-g".to_string());
}
flags.push("-Zmiri -Zunstable-options".to_string());
flags.push(build.config.cmd.rustc_args().join(" "));

if let Some(linker) = build.linker(target) {
cmd.arg("--linker").arg(linker);
Expand Down
17 changes: 17 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub enum Subcommand {
Test {
paths: Vec<PathBuf>,
test_args: Vec<String>,
rustc_args: Vec<String>,
fail_fast: bool,
},
Bench {
Expand Down Expand Up @@ -150,6 +151,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
"test" => {
opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
opts.optmulti("", "test-args", "extra arguments", "ARGS");
opts.optmulti(
"",
"rustc-args",
"extra options to pass the compiler when running tests",
"ARGS",
);
},
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
"clean" => { opts.optflag("", "all", "clean all build artifacts"); },
Expand Down Expand Up @@ -283,6 +290,7 @@ Arguments:
Subcommand::Test {
paths,
test_args: matches.opt_strs("test-args"),
rustc_args: matches.opt_strs("rustc-args"),
fail_fast: !matches.opt_present("no-fail-fast"),
}
}
Expand Down Expand Up @@ -362,6 +370,15 @@ impl Subcommand {
}
}

pub fn rustc_args(&self) -> Vec<&str> {
match *self {
Subcommand::Test { ref rustc_args, .. } => {
rustc_args.iter().flat_map(|s| s.split_whitespace()).collect()
}
_ => Vec::new(),
}
}

pub fn fail_fast(&self) -> bool {
match *self {
Subcommand::Test { fail_fast, .. } => fail_fast,
Expand Down
13 changes: 10 additions & 3 deletions src/liballoc_jemalloc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ fn main() {
// for targets like emscripten, even if we don't use it.
let target = env::var("TARGET").expect("TARGET was not set");
let host = env::var("HOST").expect("HOST was not set");
if target.contains("bitrig") || target.contains("cloudabi") || target.contains("emscripten") ||
target.contains("fuchsia") || target.contains("msvc") || target.contains("openbsd") ||
target.contains("redox") || target.contains("rumprun") || target.contains("wasm32") {
if target.contains("bitrig") || target.contains("emscripten") || target.contains("fuchsia") ||
target.contains("msvc") || target.contains("openbsd") || target.contains("redox") ||
target.contains("rumprun") || target.contains("wasm32") {
println!("cargo:rustc-cfg=dummy_jemalloc");
return;
}

// CloudABI ships with a copy of jemalloc that has been patched to
// work well with sandboxing. Don't attempt to build our own copy,
// as it won't build.
if target.contains("cloudabi") {
return;
}

if target.contains("android") {
println!("cargo:rustc-link-lib=gcc");
} else if !target.contains("windows") && !target.contains("musl") {
Expand Down
21 changes: 6 additions & 15 deletions src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use session::Session;

use std::cmp::Ord;
use std::hash as std_hash;
use std::cell::RefCell;
use std::collections::HashMap;
use std::cell::RefCell;

use syntax::ast;

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

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

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

debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
IGNORED_ATTR_NAMES.with(|names| {
let mut names = names.borrow_mut();
if names.is_empty() {
names.extend(ich::IGNORED_ATTRIBUTES.iter()
.map(|&s| Symbol::intern(s)));
}
});

StableHashingContext {
sess,
body_resolver: BodyResolver(krate),
Expand Down Expand Up @@ -186,9 +179,7 @@ impl<'gcx> StableHashingContext<'gcx> {

#[inline]
pub fn is_ignored_attr(&self, name: Symbol) -> bool {
IGNORED_ATTR_NAMES.with(|names| {
names.borrow().contains(&name)
})
self.sess.ignored_attr_names.contains(&name)
}

pub fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self, f: F) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
pub use self::fingerprint::Fingerprint;
pub use self::caching_codemap_view::CachingCodemapView;
pub use self::hcx::{StableHashingContext, NodeIdHashingMode,
hash_stable_trait_impls};
hash_stable_trait_impls, compute_ignored_attr_names};
mod fingerprint;
mod caching_codemap_view;
mod hcx;
Expand Down
36 changes: 24 additions & 12 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ macro_rules! options {
Some(::rustc_back::LinkerFlavor::one_of());
pub const parse_optimization_fuel: Option<&'static str> =
Some("crate=integer");
pub const parse_unpretty: Option<&'static str> =
Some("`string` or `string=string`");
}

#[allow(dead_code)]
Expand Down Expand Up @@ -965,6 +967,17 @@ macro_rules! options {
}
}
}

fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
match v {
None => false,
Some(s) if s.split('=').count() <= 2 => {
*slot = Some(s.to_string());
true
}
_ => false,
}
}
}
) }

Expand Down Expand Up @@ -1104,13 +1117,13 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"write syntax and type analysis (in JSON format) information, in \
addition to normal output"),
flowgraph_print_loans: bool = (false, parse_bool, [UNTRACKED],
"include loan analysis data in --unpretty flowgraph output"),
"include loan analysis data in -Z unpretty flowgraph output"),
flowgraph_print_moves: bool = (false, parse_bool, [UNTRACKED],
"include move analysis data in --unpretty flowgraph output"),
"include move analysis data in -Z unpretty flowgraph output"),
flowgraph_print_assigns: bool = (false, parse_bool, [UNTRACKED],
"include assignment analysis data in --unpretty flowgraph output"),
"include assignment analysis data in -Z unpretty flowgraph output"),
flowgraph_print_all: bool = (false, parse_bool, [UNTRACKED],
"include all dataflow analysis data in --unpretty flowgraph output"),
"include all dataflow analysis data in -Z unpretty flowgraph output"),
print_region_graph: bool = (false, parse_bool, [UNTRACKED],
"prints region inference graph. \
Use with RUST_REGION_GRAPH=help for more info"),
Expand Down Expand Up @@ -1241,6 +1254,13 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
"in dep-info output, omit targets for tracking dependencies of the dep-info files \
themselves"),
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
"Present the input source, unstable (and less-pretty) variants;
valid types are any of the types for `--pretty`, as well as:
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
`everybody_loops` (all function bodies replaced with `loop {}`),
`hir` (the HIR), `hir,identified`, or
`hir,typed` (HIR with types for each node)."),
}

pub fn default_lib_output() -> CrateType {
Expand Down Expand Up @@ -1514,14 +1534,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
`expanded` (crates expanded), or
`expanded,identified` (fully parenthesized, AST nodes with IDs).",
"TYPE"),
opt::opt("", "unpretty",
"Present the input source, unstable (and less-pretty) variants;
valid types are any of the types for `--pretty`, as well as:
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
`everybody_loops` (all function bodies replaced with `loop {}`),
`hir` (the HIR), `hir,identified`, or
`hir,typed` (HIR with types for each node).",
"TYPE"),
]);
opts
}
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub use self::code_stats::{SizeKind, TypeSizeInfo, VariantInfo};
use hir::def_id::CrateNum;
use ich::Fingerprint;

use ich;
use lint;
use middle::allocator::AllocatorKind;
use middle::dependency_format;
Expand All @@ -28,6 +29,7 @@ use errors::{self, DiagnosticBuilder, DiagnosticId};
use errors::emitter::{Emitter, EmitterWriter};
use syntax::json::JsonEmitter;
use syntax::feature_gate;
use syntax::symbol::Symbol;
use syntax::parse;
use syntax::parse::ParseSess;
use syntax::{ast, codemap};
Expand Down Expand Up @@ -112,6 +114,9 @@ pub struct Session {

incr_comp_session: RefCell<IncrCompSession>,

/// A cache of attributes ignored by StableHashingContext
pub ignored_attr_names: FxHashSet<Symbol>,

/// Some measurements that are being gathered during compilation.
pub perf_stats: PerfStats,

Expand Down Expand Up @@ -975,6 +980,7 @@ pub fn build_session_(sopts: config::Options,
injected_panic_runtime: Cell::new(None),
imported_macro_spans: RefCell::new(HashMap::new()),
incr_comp_session: RefCell::new(IncrCompSession::NotInitialized),
ignored_attr_names: ich::compute_ignored_attr_names(),
perf_stats: PerfStats {
svh_time: Cell::new(Duration::from_secs(0)),
incr_comp_hashes_time: Cell::new(Duration::from_secs(0)),
Expand Down
30 changes: 9 additions & 21 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ use std::iter;
use std::path::{Path, PathBuf};
use std::rc::Rc;
use std::sync::mpsc;
use syntax::{ast, diagnostics, visit};
use syntax::attr;
use syntax::{self, ast, attr, diagnostics, visit};
use syntax::ext::base::ExtCtxt;
use syntax::fold::Folder;
use syntax::parse::{self, PResult};
use syntax::util::node_count::NodeCounter;
use syntax_pos::FileName;
use syntax;
use syntax_ext;

use derive_registrar;
Expand Down Expand Up @@ -275,10 +273,6 @@ pub fn compile_input(trans: Box<TransCrate>,
Ok(())
}

fn keep_hygiene_data(sess: &Session) -> bool {
sess.opts.debugging_opts.keep_hygiene_data
}

pub fn source_name(input: &Input) -> FileName {
match *input {
Input::File(ref ifile) => ifile.clone().into(),
Expand Down Expand Up @@ -900,7 +894,7 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
|| lint::check_ast_crate(sess, &krate));

// Discard hygiene data, which isn't required after lowering to HIR.
if !keep_hygiene_data(sess) {
if !sess.opts.debugging_opts.keep_hygiene_data {
syntax::ext::hygiene::clear_markings();
}

Expand Down Expand Up @@ -952,18 +946,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate,
mpsc::Receiver<Box<Any + Send>>,
CompileResult) -> R
{
macro_rules! try_with_f {
($e: expr, ($($t:tt)*)) => {
match $e {
Ok(x) => x,
Err(x) => {
f($($t)*, Err(x));
return Err(x);
}
}
}
}

let time_passes = sess.time_passes();

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

// passes are timed inside typeck
try_with_f!(typeck::check_crate(tcx), (tcx, analysis, rx));
match typeck::check_crate(tcx) {
Ok(x) => x,
Err(x) => {
f(tcx, analysis, rx, Err(x));
return Err(x);
}
}

time(time_passes,
"const checking",
Expand Down
Loading

0 comments on commit 4e3901d

Please sign in to comment.