Skip to content

Commit eb29530

Browse files
committed
Rollup merge of #55391 - matthiaskrgr:bootstrap_cleanup, r=oli-obk
bootstrap: clean up a few clippy findings remove useless format!()s remove redundant field names in a few struct initializations pass slice instead of a vector to a function use is_empty() instead of comparisons to .len() No functional change intended.
2 parents 5a16579 + 54edf32 commit eb29530

File tree

6 files changed

+33
-34
lines changed

6 files changed

+33
-34
lines changed

src/bootstrap/compile.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Step for Std {
6969
if builder.config.keep_stage.contains(&compiler.stage) {
7070
builder.info("Warning: Using a potentially old libstd. This may not behave well.");
7171
builder.ensure(StdLink {
72-
compiler: compiler,
72+
compiler,
7373
target_compiler: compiler,
7474
target,
7575
});
@@ -358,7 +358,7 @@ impl Step for Test {
358358
if builder.config.keep_stage.contains(&compiler.stage) {
359359
builder.info("Warning: Using a potentially old libtest. This may not behave well.");
360360
builder.ensure(TestLink {
361-
compiler: compiler,
361+
compiler,
362362
target_compiler: compiler,
363363
target,
364364
});
@@ -480,7 +480,7 @@ impl Step for Rustc {
480480
if builder.config.keep_stage.contains(&compiler.stage) {
481481
builder.info("Warning: Using a potentially old librustc. This may not behave well.");
482482
builder.ensure(RustcLink {
483-
compiler: compiler,
483+
compiler,
484484
target_compiler: compiler,
485485
target,
486486
});
@@ -816,8 +816,8 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder,
816816
let filename = file.file_name().unwrap().to_str().unwrap();
817817
// change `librustc_codegen_llvm-xxxxxx.so` to `librustc_codegen_llvm-llvm.so`
818818
let target_filename = {
819-
let dash = filename.find("-").unwrap();
820-
let dot = filename.find(".").unwrap();
819+
let dash = filename.find('-').unwrap();
820+
let dot = filename.find('.').unwrap();
821821
format!("{}-{}{}",
822822
&filename[..dash],
823823
backend,

src/bootstrap/flags.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ impl Default for Subcommand {
9393
impl Flags {
9494
pub fn parse(args: &[String]) -> Flags {
9595
let mut extra_help = String::new();
96-
let mut subcommand_help = format!(
97-
"\
96+
let mut subcommand_help = String::from("\
9897
Usage: x.py <subcommand> [options] [<paths>...]
9998
10099
Subcommands:
@@ -365,8 +364,8 @@ Arguments:
365364
}
366365

367366
let cmd = match subcommand.as_str() {
368-
"build" => Subcommand::Build { paths: paths },
369-
"check" => Subcommand::Check { paths: paths },
367+
"build" => Subcommand::Build { paths },
368+
"check" => Subcommand::Check { paths },
370369
"test" => Subcommand::Test {
371370
paths,
372371
bless: matches.opt_present("bless"),
@@ -386,9 +385,9 @@ Arguments:
386385
paths,
387386
test_args: matches.opt_strs("test-args"),
388387
},
389-
"doc" => Subcommand::Doc { paths: paths },
388+
"doc" => Subcommand::Doc { paths },
390389
"clean" => {
391-
if paths.len() > 0 {
390+
if !paths.is_empty() {
392391
println!("\nclean does not take a path argument\n");
393392
usage(1, &opts, &subcommand_help, &extra_help);
394393
}
@@ -413,19 +412,19 @@ Arguments:
413412
keep_stage: matches.opt_strs("keep-stage")
414413
.into_iter().map(|j| j.parse().unwrap())
415414
.collect(),
416-
host: split(matches.opt_strs("host"))
415+
host: split(&matches.opt_strs("host"))
417416
.into_iter()
418417
.map(|x| INTERNER.intern_string(x))
419418
.collect::<Vec<_>>(),
420-
target: split(matches.opt_strs("target"))
419+
target: split(&matches.opt_strs("target"))
421420
.into_iter()
422421
.map(|x| INTERNER.intern_string(x))
423422
.collect::<Vec<_>>(),
424423
config: cfg_file,
425424
jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()),
426425
cmd,
427426
incremental: matches.opt_present("incremental"),
428-
exclude: split(matches.opt_strs("exclude"))
427+
exclude: split(&matches.opt_strs("exclude"))
429428
.into_iter()
430429
.map(|p| p.into())
431430
.collect::<Vec<_>>(),
@@ -488,7 +487,7 @@ impl Subcommand {
488487
}
489488
}
490489

491-
fn split(s: Vec<String>) -> Vec<String> {
490+
fn split(s: &[String]) -> Vec<String> {
492491
s.iter()
493492
.flat_map(|s| s.split(','))
494493
.map(|s| s.to_string())

src/bootstrap/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ impl Build {
768768
let sha = self.rust_sha().unwrap_or(channel::CFG_RELEASE_NUM);
769769
format!("/rustc/{}", sha)
770770
}
771-
GitRepo::Llvm => format!("/rustc/llvm"),
771+
GitRepo::Llvm => String::from("/rustc/llvm"),
772772
};
773773
Some(format!("{}={}", self.src.display(), path))
774774
}
@@ -783,7 +783,7 @@ impl Build {
783783
fn cflags(&self, target: Interned<String>, which: GitRepo) -> Vec<String> {
784784
// Filter out -O and /O (the optimization flags) that we picked up from
785785
// cc-rs because the build scripts will determine that for themselves.
786-
let mut base = self.cc[&target].args().iter()
786+
let mut base: Vec<String> = self.cc[&target].args().iter()
787787
.map(|s| s.to_string_lossy().into_owned())
788788
.filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
789789
.collect::<Vec<_>>();
@@ -806,10 +806,10 @@ impl Build {
806806
if let Some(map) = self.debuginfo_map(which) {
807807
let cc = self.cc(target);
808808
if cc.ends_with("clang") || cc.ends_with("gcc") {
809-
base.push(format!("-fdebug-prefix-map={}", map).into());
809+
base.push(format!("-fdebug-prefix-map={}", map));
810810
} else if cc.ends_with("clang-cl.exe") {
811811
base.push("-Xclang".into());
812-
base.push(format!("-fdebug-prefix-map={}", map).into());
812+
base.push(format!("-fdebug-prefix-map={}", map));
813813
}
814814
}
815815
base

src/bootstrap/sanity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn check(build: &mut Build) {
7474
// one is present as part of the PATH then that can lead to the system
7575
// being unable to identify the files properly. See
7676
// https://github.com/rust-lang/rust/issues/34959 for more details.
77-
if cfg!(windows) && path.to_string_lossy().contains("\"") {
77+
if cfg!(windows) && path.to_string_lossy().contains('\"') {
7878
panic!("PATH contains invalid character '\"'");
7979
}
8080

src/bootstrap/test.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ impl Step for RustdocTheme {
521521
fn make_run(run: RunConfig) {
522522
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
523523

524-
run.builder.ensure(RustdocTheme { compiler: compiler });
524+
run.builder.ensure(RustdocTheme { compiler });
525525
}
526526

527527
fn run(self, builder: &Builder) {
@@ -584,9 +584,9 @@ impl Step for RustdocJS {
584584
});
585585
builder.run(&mut command);
586586
} else {
587-
builder.info(&format!(
587+
builder.info(
588588
"No nodejs found, skipping \"src/test/rustdoc-js\" tests"
589-
));
589+
);
590590
}
591591
}
592592
}
@@ -653,7 +653,7 @@ impl Step for Tidy {
653653
}
654654

655655
let _folder = builder.fold_output(|| "tidy");
656-
builder.info(&format!("tidy check"));
656+
builder.info("tidy check");
657657
try_run(builder, &mut cmd);
658658
}
659659

@@ -1168,9 +1168,9 @@ impl Step for Compiletest {
11681168
}
11691169
}
11701170
if suite == "run-make-fulldeps" && !builder.config.llvm_enabled {
1171-
builder.info(&format!(
1171+
builder.info(
11721172
"Ignoring run-make test suite as they generally don't work without LLVM"
1173-
));
1173+
);
11741174
return;
11751175
}
11761176

@@ -1692,10 +1692,10 @@ impl Step for Crate {
16921692
// The javascript shim implements the syscall interface so that test
16931693
// output can be correctly reported.
16941694
if !builder.config.wasm_syscall {
1695-
builder.info(&format!(
1695+
builder.info(
16961696
"Libstd was built without `wasm_syscall` feature enabled: \
16971697
test output may not be visible."
1698-
));
1698+
);
16991699
}
17001700

17011701
// On the wasm32-unknown-unknown target we're using LTO which is
@@ -1891,7 +1891,7 @@ impl Step for Distcheck {
18911891

18921892
/// Run "distcheck", a 'make check' from a tarball
18931893
fn run(self, builder: &Builder) {
1894-
builder.info(&format!("Distcheck"));
1894+
builder.info("Distcheck");
18951895
let dir = builder.out.join("tmp").join("distcheck");
18961896
let _ = fs::remove_dir_all(&dir);
18971897
t!(fs::create_dir_all(&dir));
@@ -1919,7 +1919,7 @@ impl Step for Distcheck {
19191919
);
19201920

19211921
// Now make sure that rust-src has all of libstd's dependencies
1922-
builder.info(&format!("Distcheck rust-src"));
1922+
builder.info("Distcheck rust-src");
19231923
let dir = builder.out.join("tmp").join("distcheck-src");
19241924
let _ = fs::remove_dir_all(&dir);
19251925
t!(fs::create_dir_all(&dir));

src/bootstrap/tool.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl Step for ToolBuild {
148148
}
149149
});
150150

151-
if is_expected && duplicates.len() != 0 {
151+
if is_expected && !duplicates.is_empty() {
152152
println!("duplicate artfacts found when compiling a tool, this \
153153
typically means that something was recompiled because \
154154
a transitive dependency has different features activated \
@@ -170,7 +170,7 @@ impl Step for ToolBuild {
170170
println!(" `{}` additionally enabled features {:?} at {:?}",
171171
prev.0, &prev_features - &cur_features, prev.1);
172172
}
173-
println!("");
173+
println!();
174174
println!("to fix this you will probably want to edit the local \
175175
src/tools/rustc-workspace-hack/Cargo.toml crate, as \
176176
that will update the dependency graph to ensure that \
@@ -188,7 +188,7 @@ impl Step for ToolBuild {
188188
if !is_optional_tool {
189189
exit(1);
190190
} else {
191-
return None;
191+
None
192192
}
193193
} else {
194194
let cargo_out = builder.cargo_out(compiler, self.mode, target)
@@ -251,7 +251,7 @@ pub fn prepare_tool_cargo(
251251
if let Some(date) = info.commit_date() {
252252
cargo.env("CFG_COMMIT_DATE", date);
253253
}
254-
if features.len() > 0 {
254+
if !features.is_empty() {
255255
cargo.arg("--features").arg(&features.join(", "));
256256
}
257257
cargo

0 commit comments

Comments
 (0)