Auto merge of #42400 - frewsxcv:rollup, r=frewsxcv

Rollup of 5 pull requests

- Successful merges: #42353, #42354, #42363, #42368, #42382
- Failed merges:
This commit is contained in:
bors 2017-06-03 06:13:05 +00:00
commit 6165203c48
18 changed files with 160 additions and 48 deletions

View File

@ -232,12 +232,6 @@ fn main() {
if let Some(rpath) = rpath {
cmd.arg("-C").arg(format!("link-args={}", rpath));
}
if let Ok(s) = env::var("RUSTFLAGS") {
for flag in s.split_whitespace() {
cmd.arg(flag);
}
}
}
if target.contains("pc-windows-msvc") {

View File

@ -58,6 +58,28 @@ impl fmt::Display for TestKind {
}
}
fn try_run(build: &Build, cmd: &mut Command) {
if build.flags.cmd.no_fail_fast() {
if !build.try_run(cmd) {
let failures = build.delayed_failures.get();
build.delayed_failures.set(failures + 1);
}
} else {
build.run(cmd);
}
}
fn try_run_quiet(build: &Build, cmd: &mut Command) {
if build.flags.cmd.no_fail_fast() {
if !build.try_run_quiet(cmd) {
let failures = build.delayed_failures.get();
build.delayed_failures.set(failures + 1);
}
} else {
build.run_quiet(cmd);
}
}
/// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
///
/// This tool in `src/tools` will verify the validity of all our links in the
@ -67,7 +89,7 @@ pub fn linkcheck(build: &Build, host: &str) {
let compiler = Compiler::new(0, host);
let _time = util::timeit();
build.run(build.tool_cmd(&compiler, "linkchecker")
try_run(build, build.tool_cmd(&compiler, "linkchecker")
.arg(build.out.join(host).join("doc")));
}
@ -87,10 +109,10 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) {
let _time = util::timeit();
let mut cmd = Command::new(build.tool(&Compiler::new(0, host), "cargotest"));
build.prepare_tool_cmd(compiler, &mut cmd);
build.run(cmd.arg(&build.cargo)
try_run(build, cmd.arg(&build.cargo)
.arg(&out_dir)
.env("RUSTC", build.compiler_path(compiler))
.env("RUSTDOC", build.rustdoc(compiler)))
.env("RUSTDOC", build.rustdoc(compiler)));
}
/// Runs `cargo test` for `cargo` packaged with Rust.
@ -107,6 +129,9 @@ pub fn cargo(build: &Build, stage: u32, host: &str) {
let mut cargo = build.cargo(compiler, Mode::Tool, host, "test");
cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
if build.flags.cmd.no_fail_fast() {
cargo.arg("--no-fail-fast");
}
// Don't build tests dynamically, just a pain to work with
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@ -115,7 +140,7 @@ pub fn cargo(build: &Build, stage: u32, host: &str) {
// available.
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
build.run(cargo.env("PATH", newpath));
try_run(build, cargo.env("PATH", newpath));
}
/// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
@ -135,7 +160,7 @@ pub fn tidy(build: &Build, host: &str) {
if build.config.quiet_tests {
cmd.arg("--quiet");
}
build.run(&mut cmd);
try_run(build, &mut cmd);
}
fn testdir(build: &Build, host: &str) -> PathBuf {
@ -286,7 +311,7 @@ pub fn compiletest(build: &Build,
build.ci_env.force_coloring_in_ci(&mut cmd);
let _time = util::timeit();
build.run(&mut cmd);
try_run(build, &mut cmd);
}
/// Run `rustdoc --test` for all documentation in `src/doc`.
@ -362,9 +387,9 @@ fn markdown_test(build: &Build, compiler: &Compiler, markdown: &Path) {
cmd.arg("--test-args").arg(test_args);
if build.config.quiet_tests {
build.run_quiet(&mut cmd);
try_run_quiet(build, &mut cmd);
} else {
build.run(&mut cmd);
try_run(build, &mut cmd);
}
}
@ -419,6 +444,9 @@ pub fn krate(build: &Build,
cargo.arg("--manifest-path")
.arg(build.src.join(path).join("Cargo.toml"))
.arg("--features").arg(features);
if test_kind.subcommand() == "test" && build.flags.cmd.no_fail_fast() {
cargo.arg("--no-fail-fast");
}
match krate {
Some(krate) => {
@ -478,7 +506,7 @@ pub fn krate(build: &Build,
krate_remote(build, &compiler, target, mode);
} else {
cargo.args(&build.flags.cmd.test_args());
build.run(&mut cargo);
try_run(build, &mut cargo);
}
}
@ -499,7 +527,7 @@ fn krate_emscripten(build: &Build,
if build.config.quiet_tests {
cmd.arg("--quiet");
}
build.run(&mut cmd);
try_run(build, &mut cmd);
}
}
@ -521,7 +549,7 @@ fn krate_remote(build: &Build,
cmd.arg("--quiet");
}
cmd.args(&build.flags.cmd.test_args());
build.run(&mut cmd);
try_run(build, &mut cmd);
}
}
@ -637,6 +665,9 @@ pub fn bootstrap(build: &Build) {
.current_dir(build.src.join("src/bootstrap"))
.env("CARGO_TARGET_DIR", build.out.join("bootstrap"))
.env("RUSTC", &build.rustc);
if build.flags.cmd.no_fail_fast() {
cmd.arg("--no-fail-fast");
}
cmd.arg("--").args(&build.flags.cmd.test_args());
build.run(&mut cmd);
try_run(build, &mut cmd);
}

View File

@ -61,6 +61,7 @@ pub enum Subcommand {
Test {
paths: Vec<PathBuf>,
test_args: Vec<String>,
no_fail_fast: bool,
},
Bench {
paths: Vec<PathBuf>,
@ -141,7 +142,10 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
// Some subcommands get extra options
match subcommand.as_str() {
"test" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
"test" => {
opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
opts.optmulti("", "test-args", "extra arguments", "ARGS");
},
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
_ => { },
};
@ -263,6 +267,7 @@ Arguments:
Subcommand::Test {
paths: paths,
test_args: matches.opt_strs("test-args"),
no_fail_fast: matches.opt_present("no-fail-fast"),
}
}
"bench" => {
@ -342,6 +347,13 @@ impl Subcommand {
_ => Vec::new(),
}
}
pub fn no_fail_fast(&self) -> bool {
match *self {
Subcommand::Test { no_fail_fast, .. } => no_fail_fast,
_ => false,
}
}
}
fn split(s: Vec<String>) -> Vec<String> {

View File

@ -79,6 +79,7 @@ extern crate toml;
#[cfg(unix)]
extern crate libc;
use std::cell::Cell;
use std::cmp;
use std::collections::HashMap;
use std::env;
@ -88,7 +89,7 @@ use std::io::Read;
use std::path::{PathBuf, Path};
use std::process::Command;
use build_helper::{run_silent, run_suppressed, output, mtime};
use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppressed, output, mtime};
use util::{exe, libdir, add_lib_path, OutputFolder, CiEnv};
@ -180,6 +181,7 @@ pub struct Build {
is_sudo: bool,
src_is_git: bool,
ci_env: CiEnv,
delayed_failures: Cell<usize>,
}
#[derive(Debug)]
@ -274,6 +276,7 @@ impl Build {
is_sudo: is_sudo,
src_is_git: src_is_git,
ci_env: CiEnv::current(),
delayed_failures: Cell::new(0),
}
}
@ -784,6 +787,22 @@ impl Build {
run_suppressed(cmd)
}
/// Runs a command, printing out nice contextual information if it fails.
/// Exits if the command failed to execute at all, otherwise returns its
/// `status.success()`.
fn try_run(&self, cmd: &mut Command) -> bool {
self.verbose(&format!("running: {:?}", cmd));
try_run_silent(cmd)
}
/// Runs a command, printing out nice contextual information if it fails.
/// Exits if the command failed to execute at all, otherwise returns its
/// `status.success()`.
fn try_run_quiet(&self, cmd: &mut Command) -> bool {
self.verbose(&format!("running: {:?}", cmd));
try_run_suppressed(cmd)
}
/// Prints a message if this build is configured in verbose mode.
fn verbose(&self, msg: &str) {
if self.flags.verbose() || self.config.verbose() {

View File

@ -184,7 +184,7 @@ pub fn llvm(build: &Build, target: &str) {
configure_compilers(&mut cfg);
if env::var_os("SCCACHE_ERROR_LOG").is_some() {
cfg.env("RUST_LOG", "sccache=info");
cfg.env("RUST_LOG", "sccache=warn");
}
// FIXME: we don't actually need to build all LLVM tools and all LLVM

View File

@ -28,6 +28,7 @@
use std::collections::{BTreeMap, HashSet, HashMap};
use std::mem;
use std::process;
use check::{self, TestKind};
use compile;
@ -1174,8 +1175,8 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
let (kind, paths) = match self.build.flags.cmd {
Subcommand::Build { ref paths } => (Kind::Build, &paths[..]),
Subcommand::Doc { ref paths } => (Kind::Doc, &paths[..]),
Subcommand::Test { ref paths, test_args: _ } => (Kind::Test, &paths[..]),
Subcommand::Bench { ref paths, test_args: _ } => (Kind::Bench, &paths[..]),
Subcommand::Test { ref paths, .. } => (Kind::Test, &paths[..]),
Subcommand::Bench { ref paths, .. } => (Kind::Bench, &paths[..]),
Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]),
Subcommand::Install { ref paths } => (Kind::Install, &paths[..]),
Subcommand::Clean => panic!(),
@ -1268,6 +1269,13 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
self.build.verbose(&format!("executing step {:?}", step));
(self.rules[step.name].run)(step);
}
// Check for postponed failures from `test --no-fail-fast`.
let failures = self.build.delayed_failures.get();
if failures > 0 {
println!("\n{} command(s) did not execute successfully.\n", failures);
process::exit(1);
}
}
/// From the top level targets `steps` generate a topological ordering of

View File

@ -42,35 +42,49 @@ pub fn run(cmd: &mut Command) {
}
pub fn run_silent(cmd: &mut Command) {
if !try_run_silent(cmd) {
std::process::exit(1);
}
}
pub fn try_run_silent(cmd: &mut Command) -> bool {
let status = match cmd.status() {
Ok(status) => status,
Err(e) => fail(&format!("failed to execute command: {:?}\nerror: {}",
cmd, e)),
};
if !status.success() {
fail(&format!("command did not execute successfully: {:?}\n\
expected success, got: {}",
println!("\n\ncommand did not execute successfully: {:?}\n\
expected success, got: {}\n\n",
cmd,
status));
status);
}
status.success()
}
pub fn run_suppressed(cmd: &mut Command) {
if !try_run_suppressed(cmd) {
std::process::exit(1);
}
}
pub fn try_run_suppressed(cmd: &mut Command) -> bool {
let output = match cmd.output() {
Ok(status) => status,
Err(e) => fail(&format!("failed to execute command: {:?}\nerror: {}",
cmd, e)),
};
if !output.status.success() {
fail(&format!("command did not execute successfully: {:?}\n\
println!("\n\ncommand did not execute successfully: {:?}\n\
expected success, got: {}\n\n\
stdout ----\n{}\n\
stderr ----\n{}\n",
stderr ----\n{}\n\n",
cmd,
output.status,
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)));
String::from_utf8_lossy(&output.stderr));
}
output.status.success()
}
pub fn gnu_target(target: &str) -> String {

View File

@ -79,6 +79,7 @@ exec docker \
--env DEPLOY_ALT=$DEPLOY_ALT \
--env LOCAL_USER_ID=`id -u` \
--env TRAVIS=${TRAVIS-false} \
--env TRAVIS_BRANCH \
--volume "$HOME/.cargo:/cargo" \
--volume "$HOME/rustsrc:$HOME/rustsrc" \
--privileged \

View File

@ -23,6 +23,10 @@ fi
ci_dir=`cd $(dirname $0) && pwd`
source "$ci_dir/shared.sh"
if [ "$TRAVIS" == "true" ] && [ "$TRAVIS_BRANCH" != "auto" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests"
fi
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"

@ -1 +1 @@
Subproject commit 97422981c53a00f7c3d6584d363443117f179fff
Subproject commit f746084b099060f55ac5e7d8050797593fcedd6e

@ -1 +1 @@
Subproject commit 6fa139b1630a9bb95dcd60cfc90aff9c19e54580
Subproject commit c0e8c56d76bdf6bd16c64338f81c04d48c60f117

@ -1 +1 @@
Subproject commit f7a108dfa9e90b07821700c55d01f08a9adf005c
Subproject commit 876582e9d0fbdc9cecb03133c28db96e9ff8c844

View File

@ -705,11 +705,9 @@ impl EmitterWriter {
if *sp == DUMMY_SP {
continue;
}
if cm.span_to_filename(sp.clone()).contains("macros>") {
let v = sp.macro_backtrace();
if let Some(use_site) = v.last() {
before_after.push((sp.clone(), use_site.call_site.clone()));
}
let call_sp = cm.call_span_if_macro(*sp);
if call_sp != *sp {
before_after.push((sp.clone(), call_sp));
}
for trace in sp.macro_backtrace().iter().rev() {
// Only show macro locations that are local

View File

@ -102,6 +102,7 @@ pub trait CodeMapper {
fn span_to_string(&self, sp: Span) -> String;
fn span_to_filename(&self, sp: Span) -> FileName;
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
fn call_span_if_macro(&self, sp: Span) -> Span;
}
impl CodeSuggestion {

View File

@ -18,7 +18,7 @@ use syntax_pos::{self, Span};
use rustc::hir;
use rustc::hir::def::Def;
use rustc::ty::{self, Ty, AssociatedItem};
use errors::DiagnosticBuilder;
use errors::{DiagnosticBuilder, CodeMapper};
use super::method::probe;
@ -187,7 +187,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
checked_ty),
};
if self.can_coerce(ref_ty, expected) {
if let Ok(src) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
// Use the callsite's span if this is a macro call. #41858
let sp = self.sess().codemap().call_span_if_macro(expr.span);
if let Ok(src) = self.tcx.sess.codemap().span_to_snippet(sp) {
return Some(format!("try with `{}{}`",
match mutability.mutbl {
hir::Mutability::MutMutable => "&mut ",

View File

@ -563,6 +563,15 @@ impl CodeMapper for CodeMap {
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span> {
self.merge_spans(sp_lhs, sp_rhs)
}
fn call_span_if_macro(&self, sp: Span) -> Span {
if self.span_to_filename(sp.clone()).contains("macros>") {
let v = sp.macro_backtrace();
if let Some(use_site) = v.last() {
return use_site.call_site;
}
}
sp
}
}
#[derive(Clone)]

View File

@ -43,4 +43,12 @@ fn main() {
//~| NOTE cyclic type of infinite size
//~| NOTE expected type `_`
//~| NOTE found type `Box<_>`
let s = &mut String::new();
s = format!("foo");
//~^ ERROR E0308
//~| NOTE expected mutable reference, found struct `std::string::String`
//~| NOTE expected type `&mut std::string::String`
//~| HELP try with `&mut format!("foo")`
//~| NOTE this error originates in a macro outside of the current crate
}

View File

@ -47,5 +47,16 @@ error[E0308]: mismatched types
= note: expected type `_`
found type `std::boxed::Box<_>`
error[E0308]: mismatched types
--> $DIR/coerce-suggestions.rs:48:9
|
48 | s = format!("foo");
| ^^^^^^^^^^^^^^ expected mutable reference, found struct `std::string::String`
|
= note: expected type `&mut std::string::String`
found type `std::string::String`
= help: try with `&mut format!("foo")`
= note: this error originates in a macro outside of the current crate
error: aborting due to previous error(s)