Skip to content

Commit 9b0115c

Browse files
committed
Consistently use a string to represent a submodule.
This makes it easier to call these functions without needing to form a Path.
1 parent f76ab64 commit 9b0115c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Diff for: src/bootstrap/src/core/build_steps/llvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl LdFlags {
8989
/// if not).
9090
pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> LlvmBuildStatus {
9191
// If we have llvm submodule initialized already, sync it.
92-
builder.update_existing_submodule(&Path::new("src").join("llvm-project"));
92+
builder.update_existing_submodule("src/llvm-project");
9393

9494
builder.config.maybe_download_ci_llvm();
9595

Diff for: src/bootstrap/src/lib.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl Build {
441441
// Cargo.toml files.
442442
let rust_submodules = ["library/backtrace", "library/stdarch"];
443443
for s in rust_submodules {
444-
build.update_submodule(Path::new(s));
444+
build.update_submodule(s);
445445
}
446446
// Now, update all existing submodules.
447447
build.update_existing_submodules();
@@ -479,7 +479,7 @@ impl Build {
479479
/// tarball). Typically [`Build::require_and_update_submodule`] should be
480480
/// used instead to provide a nice error to the user if the submodule is
481481
/// missing.
482-
fn update_submodule(&self, relative_path: &Path) {
482+
fn update_submodule(&self, relative_path: &str) {
483483
if !self.config.submodules() {
484484
return;
485485
}
@@ -527,7 +527,7 @@ impl Build {
527527
return;
528528
}
529529

530-
println!("Updating submodule {}", relative_path.display());
530+
println!("Updating submodule {relative_path}");
531531
helpers::git(Some(&self.src))
532532
.run_always()
533533
.args(["submodule", "-q", "sync"])
@@ -596,9 +596,8 @@ impl Build {
596596
if cfg!(test) && !self.config.submodules() {
597597
return;
598598
}
599-
let relative_path = Path::new(submodule);
600-
self.update_submodule(relative_path);
601-
let absolute_path = self.config.src.join(relative_path);
599+
self.update_submodule(submodule);
600+
let absolute_path = self.config.src.join(submodule);
602601
if dir_is_empty(&absolute_path) {
603602
let maybe_enable = if !self.config.submodules()
604603
&& self.config.rust_info.is_managed_git_subrepository()
@@ -642,22 +641,23 @@ impl Build {
642641
for line in output.lines() {
643642
// Look for `submodule.$name.path = $path`
644643
// Sample output: `submodule.src/rust-installer.path src/tools/rust-installer`
645-
let submodule = Path::new(line.split_once(' ').unwrap().1);
644+
let submodule = line.split_once(' ').unwrap().1;
645+
let path = Path::new(submodule);
646646
// Don't update the submodule unless it's already been cloned.
647-
if GitInfo::new(false, submodule).is_managed_git_subrepository() {
647+
if GitInfo::new(false, path).is_managed_git_subrepository() {
648648
self.update_submodule(submodule);
649649
}
650650
}
651651
}
652652

653653
/// Updates the given submodule only if it's initialized already; nothing happens otherwise.
654-
pub fn update_existing_submodule(&self, submodule: &Path) {
654+
pub fn update_existing_submodule(&self, submodule: &str) {
655655
// Avoid running git when there isn't a git checkout.
656656
if !self.config.submodules() {
657657
return;
658658
}
659659

660-
if GitInfo::new(false, submodule).is_managed_git_subrepository() {
660+
if GitInfo::new(false, Path::new(submodule)).is_managed_git_subrepository() {
661661
self.update_submodule(submodule);
662662
}
663663
}

0 commit comments

Comments
 (0)