Skip to content

Commit 4ff8fb9

Browse files
committed
Auto merge of #68831 - Dylan-DPC:rollup-j6x15y9, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #68282 (Instrument C / C++ in MemorySanitizer example) - #68758 (Fix 59191 - ICE when macro replaces crate root with non-module item) - #68805 (bootstrap: fix clippy warnings) - #68810 (Remove Copy impl from OnceWith) - #68815 (remove redundant imports (clippy::single_component_path_imports)) - #68818 (fix couple of perf related clippy warnings) - #68819 (Suggest `split_at_mut` on multiple mutable index access) Failed merges: r? @ghost
2 parents 002287d + 793a5e6 commit 4ff8fb9

File tree

52 files changed

+156
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+156
-114
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn main() {
4747
};
4848
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
4949
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
50-
let on_fail = env::var_os("RUSTC_ON_FAIL").map(|of| Command::new(of));
50+
let on_fail = env::var_os("RUSTC_ON_FAIL").map(Command::new);
5151

5252
let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
5353
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
@@ -64,7 +64,7 @@ fn main() {
6464
if let Some(crate_name) = crate_name {
6565
if let Some(target) = env::var_os("RUSTC_TIME") {
6666
if target == "all"
67-
|| target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
67+
|| target.into_string().unwrap().split(',').any(|c| c.trim() == crate_name)
6868
{
6969
cmd.arg("-Ztime");
7070
}
@@ -189,7 +189,7 @@ fn main() {
189189
crate_name,
190190
is_test,
191191
dur.as_secs(),
192-
dur.subsec_nanos() / 1_000_000
192+
dur.subsec_millis()
193193
);
194194

195195
match status.code() {

src/bootstrap/bin/rustdoc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn main() {
6161
}
6262

6363
// Needed to be able to run all rustdoc tests.
64-
if let Some(_) = env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES") {
64+
if env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES").is_some() {
6565
// This "unstable-options" can be removed when `--generate-redirect-pages` is stabilized
6666
if !has_unstable {
6767
cmd.arg("-Z").arg("unstable-options");

src/bootstrap/builder.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,15 @@ impl<'a> Builder<'a> {
510510
Subcommand::Format { .. } | Subcommand::Clean { .. } => panic!(),
511511
};
512512

513-
let builder = Builder {
513+
Builder {
514514
build,
515515
top_stage: build.config.stage.unwrap_or(2),
516516
kind,
517517
cache: Cache::new(),
518518
stack: RefCell::new(Vec::new()),
519519
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
520520
paths: paths.to_owned(),
521-
};
522-
523-
builder
521+
}
524522
}
525523

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

756-
let stage;
757-
if compiler.stage == 0 && self.local_rebuild {
754+
let stage = if compiler.stage == 0 && self.local_rebuild {
758755
// Assume the local-rebuild rustc already has stage1 features.
759-
stage = 1;
756+
1
760757
} else {
761-
stage = compiler.stage;
762-
}
758+
compiler.stage
759+
};
763760

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

12541251
if self.config.print_step_timings && dur > Duration::from_millis(100) {
1255-
println!(
1256-
"[TIMING] {:?} -- {}.{:03}",
1257-
step,
1258-
dur.as_secs(),
1259-
dur.subsec_nanos() / 1_000_000
1260-
);
1252+
println!("[TIMING] {:?} -- {}.{:03}", step, dur.as_secs(), dur.subsec_millis());
12611253
}
12621254

12631255
{
@@ -1302,7 +1294,7 @@ impl Rustflags {
13021294

13031295
fn arg(&mut self, arg: &str) -> &mut Self {
13041296
assert_eq!(arg.split_whitespace().count(), 1);
1305-
if self.0.len() > 0 {
1297+
if !self.0.is_empty() {
13061298
self.0.push_str(" ");
13071299
}
13081300
self.0.push_str(arg);

src/bootstrap/builder/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ fn configure(host: &[&str], target: &[&str]) -> Config {
1919
config.out = dir;
2020
config.build = INTERNER.intern_str("A");
2121
config.hosts = vec![config.build]
22-
.clone()
2322
.into_iter()
2423
.chain(host.iter().map(|s| INTERNER.intern_str(s)))
2524
.collect::<Vec<_>>();

src/bootstrap/compile.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use std::str;
1818
use build_helper::{output, t, up_to_date};
1919
use filetime::FileTime;
2020
use serde::Deserialize;
21-
use serde_json;
2221

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

@@ -361,7 +361,7 @@ impl Step for StartupObjects {
361361
);
362362
}
363363

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

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

521521
if let Some(ref ver_date) = builder.rust_info.commit_date() {
@@ -843,11 +843,11 @@ pub fn run_cargo(
843843
};
844844
for filename in filenames {
845845
// Skip files like executables
846-
if !filename.ends_with(".rlib")
847-
&& !filename.ends_with(".lib")
848-
&& !filename.ends_with(".a")
849-
&& !is_dylib(&filename)
850-
&& !(is_check && filename.ends_with(".rmeta"))
846+
if !(filename.ends_with(".rlib")
847+
|| filename.ends_with(".lib")
848+
|| filename.ends_with(".a")
849+
|| is_dylib(&filename)
850+
|| (is_check && filename.ends_with(".rmeta")))
851851
{
852852
continue;
853853
}
@@ -905,7 +905,7 @@ pub fn run_cargo(
905905
for (prefix, extension, expected_len) in toplevel {
906906
let candidates = contents.iter().filter(|&&(_, ref filename, ref meta)| {
907907
filename.starts_with(&prefix[..])
908-
&& filename[prefix.len()..].starts_with("-")
908+
&& filename[prefix.len()..].starts_with('-')
909909
&& filename.ends_with(&extension[..])
910910
&& meta.len() == expected_len
911911
});

src/bootstrap/config.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::flags::Flags;
1616
pub use crate::flags::Subcommand;
1717
use build_helper::t;
1818
use serde::Deserialize;
19-
use toml;
2019

2120
/// Global configuration for the entire build and/or bootstrap.
2221
///
@@ -440,7 +439,7 @@ impl Config {
440439
}
441440
}
442441
})
443-
.unwrap_or_else(|| TomlConfig::default());
442+
.unwrap_or_else(TomlConfig::default);
444443

445444
let build = toml.build.clone().unwrap_or_default();
446445
// set by bootstrap.py
@@ -539,7 +538,7 @@ impl Config {
539538
config.llvm_ldflags = llvm.ldflags.clone();
540539
set(&mut config.llvm_use_libcxx, llvm.use_libcxx);
541540
config.llvm_use_linker = llvm.use_linker.clone();
542-
config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.clone();
541+
config.llvm_allow_old_toolchain = llvm.allow_old_toolchain;
543542
}
544543

545544
if let Some(ref rust) = toml.rust {
@@ -606,7 +605,7 @@ impl Config {
606605
target.ar = cfg.ar.clone().map(PathBuf::from);
607606
target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
608607
target.linker = cfg.linker.clone().map(PathBuf::from);
609-
target.crt_static = cfg.crt_static.clone();
608+
target.crt_static = cfg.crt_static;
610609
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
611610
target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
612611
target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);

src/bootstrap/dist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ impl Step for Analysis {
828828
assert!(builder.config.extended);
829829
let name = pkgname(builder, "rust-analysis");
830830

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

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

src/bootstrap/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ impl Step for Rustdoc {
560560
builder.ensure(Rustc { stage, target });
561561

562562
// Build rustdoc.
563-
builder.ensure(tool::Rustdoc { compiler: compiler });
563+
builder.ensure(tool::Rustdoc { compiler });
564564

565565
// Symlink compiler docs to the output directory of rustdoc documentation.
566566
let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target).join("doc");

src/bootstrap/flags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ fn split(s: &[String]) -> Vec<String> {
571571
}
572572

573573
fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
574-
match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
574+
match matches.opt_str("warnings").as_deref() {
575575
Some("deny") => Some(true),
576576
Some("warn") => Some(false),
577577
Some(value) => {

src/bootstrap/install.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,8 @@ fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf {
126126
None => return path.to_path_buf(),
127127
};
128128
for part in path.components() {
129-
match part {
130-
Component::Normal(s) => ret.push(s),
131-
_ => {}
129+
if let Component::Normal(s) = part {
130+
ret.push(s)
132131
}
133132
}
134133
ret

0 commit comments

Comments
 (0)