Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #68831

Merged
merged 16 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() {
};
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
let on_fail = env::var_os("RUSTC_ON_FAIL").map(|of| Command::new(of));
let on_fail = env::var_os("RUSTC_ON_FAIL").map(Command::new);

let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
Expand All @@ -64,7 +64,7 @@ fn main() {
if let Some(crate_name) = crate_name {
if let Some(target) = env::var_os("RUSTC_TIME") {
if target == "all"
|| target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
|| target.into_string().unwrap().split(',').any(|c| c.trim() == crate_name)
{
cmd.arg("-Ztime");
}
Expand Down Expand Up @@ -189,7 +189,7 @@ fn main() {
crate_name,
is_test,
dur.as_secs(),
dur.subsec_nanos() / 1_000_000
dur.subsec_millis()
);

match status.code() {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn main() {
}

// Needed to be able to run all rustdoc tests.
if let Some(_) = env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES") {
if env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES").is_some() {
// This "unstable-options" can be removed when `--generate-redirect-pages` is stabilized
if !has_unstable {
cmd.arg("-Z").arg("unstable-options");
Expand Down
24 changes: 8 additions & 16 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,17 +510,15 @@ impl<'a> Builder<'a> {
Subcommand::Format { .. } | Subcommand::Clean { .. } => panic!(),
};

let builder = Builder {
Builder {
build,
top_stage: build.config.stage.unwrap_or(2),
kind,
cache: Cache::new(),
stack: RefCell::new(Vec::new()),
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
paths: paths.to_owned(),
};

builder
}
}

pub fn execute_cli(&self) {
Expand Down Expand Up @@ -753,13 +751,12 @@ impl<'a> Builder<'a> {
cargo.env("RUST_CHECK", "1");
}

let stage;
if compiler.stage == 0 && self.local_rebuild {
let stage = if compiler.stage == 0 && self.local_rebuild {
// Assume the local-rebuild rustc already has stage1 features.
stage = 1;
1
} else {
stage = compiler.stage;
}
compiler.stage
};

let mut rustflags = Rustflags::new(&target);
if stage != 0 {
Expand Down Expand Up @@ -1252,12 +1249,7 @@ impl<'a> Builder<'a> {
};

if self.config.print_step_timings && dur > Duration::from_millis(100) {
println!(
"[TIMING] {:?} -- {}.{:03}",
step,
dur.as_secs(),
dur.subsec_nanos() / 1_000_000
);
println!("[TIMING] {:?} -- {}.{:03}", step, dur.as_secs(), dur.subsec_millis());
}

{
Expand Down Expand Up @@ -1302,7 +1294,7 @@ impl Rustflags {

fn arg(&mut self, arg: &str) -> &mut Self {
assert_eq!(arg.split_whitespace().count(), 1);
if self.0.len() > 0 {
if !self.0.is_empty() {
self.0.push_str(" ");
}
self.0.push_str(arg);
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ fn configure(host: &[&str], target: &[&str]) -> Config {
config.out = dir;
config.build = INTERNER.intern_str("A");
config.hosts = vec![config.build]
.clone()
.into_iter()
.chain(host.iter().map(|s| INTERNER.intern_str(s)))
.collect::<Vec<_>>();
Expand Down
20 changes: 10 additions & 10 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use std::str;
use build_helper::{output, t, up_to_date};
use filetime::FileTime;
use serde::Deserialize;
use serde_json;

use crate::builder::Cargo;
use crate::dist;
Expand Down Expand Up @@ -149,7 +148,8 @@ fn copy_third_party_objects(
// which is provided by std for this target.
if target == "x86_64-fortanix-unknown-sgx" {
let src_path_env = "X86_FORTANIX_SGX_LIBS";
let src = env::var(src_path_env).expect(&format!("{} not found in env", src_path_env));
let src =
env::var(src_path_env).unwrap_or_else(|_| panic!("{} not found in env", src_path_env));
copy_and_stamp(Path::new(&src), "libunwind.a");
}

Expand Down Expand Up @@ -361,7 +361,7 @@ impl Step for StartupObjects {
);
}

let target = sysroot_dir.join(file.to_string() + ".o");
let target = sysroot_dir.join((*file).to_string() + ".o");
builder.copy(dst_file, &target);
target_deps.push(target);
}
Expand Down Expand Up @@ -515,7 +515,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: Interne
.env("CFG_VERSION", builder.rust_version())
.env("CFG_PREFIX", builder.config.prefix.clone().unwrap_or_default());

let libdir_relative = builder.config.libdir_relative().unwrap_or(Path::new("lib"));
let libdir_relative = builder.config.libdir_relative().unwrap_or_else(|| Path::new("lib"));
cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);

if let Some(ref ver_date) = builder.rust_info.commit_date() {
Expand Down Expand Up @@ -843,11 +843,11 @@ pub fn run_cargo(
};
for filename in filenames {
// Skip files like executables
if !filename.ends_with(".rlib")
&& !filename.ends_with(".lib")
&& !filename.ends_with(".a")
&& !is_dylib(&filename)
&& !(is_check && filename.ends_with(".rmeta"))
if !(filename.ends_with(".rlib")
|| filename.ends_with(".lib")
|| filename.ends_with(".a")
|| is_dylib(&filename)
|| (is_check && filename.ends_with(".rmeta")))
{
continue;
}
Expand Down Expand Up @@ -905,7 +905,7 @@ pub fn run_cargo(
for (prefix, extension, expected_len) in toplevel {
let candidates = contents.iter().filter(|&&(_, ref filename, ref meta)| {
filename.starts_with(&prefix[..])
&& filename[prefix.len()..].starts_with("-")
&& filename[prefix.len()..].starts_with('-')
&& filename.ends_with(&extension[..])
&& meta.len() == expected_len
});
Expand Down
7 changes: 3 additions & 4 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::flags::Flags;
pub use crate::flags::Subcommand;
use build_helper::t;
use serde::Deserialize;
use toml;

/// Global configuration for the entire build and/or bootstrap.
///
Expand Down Expand Up @@ -440,7 +439,7 @@ impl Config {
}
}
})
.unwrap_or_else(|| TomlConfig::default());
.unwrap_or_else(TomlConfig::default);

let build = toml.build.clone().unwrap_or_default();
// set by bootstrap.py
Expand Down Expand Up @@ -539,7 +538,7 @@ impl Config {
config.llvm_ldflags = llvm.ldflags.clone();
set(&mut config.llvm_use_libcxx, llvm.use_libcxx);
config.llvm_use_linker = llvm.use_linker.clone();
config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.clone();
config.llvm_allow_old_toolchain = llvm.allow_old_toolchain;
}

if let Some(ref rust) = toml.rust {
Expand Down Expand Up @@ -606,7 +605,7 @@ impl Config {
target.ar = cfg.ar.clone().map(PathBuf::from);
target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
target.linker = cfg.linker.clone().map(PathBuf::from);
target.crt_static = cfg.crt_static.clone();
target.crt_static = cfg.crt_static;
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ impl Step for Analysis {
assert!(builder.config.extended);
let name = pkgname(builder, "rust-analysis");

if &compiler.host != builder.config.build {
if compiler.host != builder.config.build {
return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
}

Expand Down Expand Up @@ -877,7 +877,7 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str]
Some(path) => path,
None => return false,
};
if spath.ends_with("~") || spath.ends_with(".pyc") {
if spath.ends_with('~') || spath.ends_with(".pyc") {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl Step for Rustdoc {
builder.ensure(Rustc { stage, target });

// Build rustdoc.
builder.ensure(tool::Rustdoc { compiler: compiler });
builder.ensure(tool::Rustdoc { compiler });

// Symlink compiler docs to the output directory of rustdoc documentation.
let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target).join("doc");
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ fn split(s: &[String]) -> Vec<String> {
}

fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
match matches.opt_str("warnings").as_deref() {
Some("deny") => Some(true),
Some("warn") => Some(false),
Some(value) => {
Expand Down
5 changes: 2 additions & 3 deletions src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf {
None => return path.to_path_buf(),
};
for part in path.components() {
match part {
Component::Normal(s) => ret.push(s),
_ => {}
if let Component::Normal(s) = part {
ret.push(s)
}
}
ret
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl Build {
builder.execute_cli();
} else {
let builder = builder::Builder::new(&self);
let _ = builder.execute_cli();
builder.execute_cli();
}

// Check for postponed failures from `test --no-fail-fast`.
Expand Down Expand Up @@ -839,7 +839,7 @@ impl Build {
.target_config
.get(&target)
.and_then(|t| t.musl_root.as_ref())
.or(self.config.musl_root.as_ref())
.or_else(|| self.config.musl_root.as_ref())
.map(|p| &**p)
}

Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::process::Command;

use build_helper::output;
use serde::Deserialize;
use serde_json;

use crate::cache::INTERNER;
use crate::{Build, Crate};
Expand Down
4 changes: 1 addition & 3 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use std::path::{Path, PathBuf};
use std::process::Command;

use build_helper::{output, t};
use cc;
use cmake;

use crate::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::cache::Interned;
Expand Down Expand Up @@ -205,7 +203,7 @@ impl Step for Llvm {
cfg.define("LLVM_ENABLE_LIBXML2", "OFF");
}

if enabled_llvm_projects.len() > 0 {
if !enabled_llvm_projects.is_empty() {
enabled_llvm_projects.sort();
enabled_llvm_projects.dedup();
cfg.define("LLVM_ENABLE_PROJECTS", enabled_llvm_projects.join(";"));
Expand Down
9 changes: 3 additions & 6 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,13 +1424,10 @@ impl Step for ErrorIndex {
}

fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool {
match fs::read_to_string(markdown) {
Ok(contents) => {
if !contents.contains("```") {
return true;
}
if let Ok(contents) = fs::read_to_string(markdown) {
if !contents.contains("```") {
return true;
}
Err(_) => {}
}

builder.info(&format!("doc tests for: {}", markdown.display()));
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub fn prepare_tool_cargo(
cargo.env("RUSTC_EXTERNAL_TOOL", "1");
}

let mut features = extra_features.iter().cloned().collect::<Vec<_>>();
let mut features = extra_features.to_vec();
if builder.build.config.cargo_native_static {
if path.ends_with("cargo")
|| path.ends_with("rls")
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/toolstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
let output = t!(String::from_utf8(output.stdout));

for (tool, submodule) in STABLE_TOOLS.iter().chain(NIGHTLY_TOOLS.iter()) {
let changed = output.lines().any(|l| l.starts_with("M") && l.ends_with(submodule));
let changed = output.lines().any(|l| l.starts_with('M') && l.ends_with(submodule));
eprintln!("Verifying status of {}...", tool);
if !changed {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Drop for TimeIt {
fn drop(&mut self) {
let time = self.1.elapsed();
if !self.0 {
println!("\tfinished in {}.{:03}", time.as_secs(), time.subsec_nanos() / 1_000_000);
println!("\tfinished in {}.{:03}", time.as_secs(), time.subsec_millis());
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/doc/unstable-book/src/compiler-flags/sanitizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Shadow byte legend (one shadow byte represents 8 application bytes):
## MemorySanitizer

Use of uninitialized memory. Note that we are using `-Zbuild-std` to instrument
standard library, and passing `-msan-track-origins=2` to the LLVM to track
the standard library, and passing `-Zsanitizer-track-origins` to track the
origins of uninitialized memory:

```shell
Expand All @@ -185,7 +185,15 @@ fn main() {
}
}

$ env RUSTFLAGS="-Zsanitizer=memory -Cllvm-args=-msan-track-origins=2" cargo -Zbuild-std run --target x86_64-unknown-linux-gnu
$ export \
CC=clang \
CXX=clang++ \
CFLAGS='-fsanitize=memory -fsanitize-memory-track-origins' \
CXXFLAGS='-fsanitize=memory -fsanitize-memory-track-origins' \
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins' \
RUSTDOCFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins'
$ cargo clean
$ cargo -Zbuild-std run --target x86_64-unknown-linux-gnu
==9416==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x560c04f7488a in core::fmt::num::imp::fmt_u64::haa293b0b098501ca $RUST/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/src/libcore/fmt/num.rs:202:16
...
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ pub fn once<T>(value: T) -> Once<T> {
/// See its documentation for more.
///
/// [`once_with`]: fn.once_with.html
#[derive(Copy, Clone, Debug)]
#[derive(Clone, Debug)]
#[stable(feature = "iter_once_with", since = "1.43.0")]
pub struct OnceWith<F> {
gen: Option<F>,
Expand Down
1 change: 0 additions & 1 deletion src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use crate::ty::subst::{InternalSubsts, SubstsRef};
use crate::ty::{self, AdtKind, GenericParamDefKind, List, ToPredicate, Ty, TyCtxt, WithConstness};
use crate::util::common::ErrorReported;
use chalk_engine;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_macros::HashStable;
Expand Down
1 change: 0 additions & 1 deletion src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::traits;
use crate::traits::project::Normalized;
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use crate::ty::{self, Lift, Ty, TyCtxt};
use chalk_engine;
use rustc_span::symbol::Symbol;
use smallvec::SmallVec;

Expand Down
Loading