Skip to content

Commit 5e61dcb

Browse files
Fix x not to quit when x prints settings.json
1 parent 8b6a4a9 commit 5e61dcb

File tree

1 file changed

+11
-5
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+11
-5
lines changed

src/bootstrap/src/core/build_steps/setup.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,18 @@ impl Step for Vscode {
549549
if config.dry_run() {
550550
return;
551551
}
552-
t!(create_vscode_settings_maybe(&config));
552+
loop {
553+
let created = t!(create_vscode_settings_maybe(&config));
554+
if created {
555+
break;
556+
}
557+
}
553558
}
554559
}
555560

556561
/// Create a `.vscode/settings.json` file for rustc development, or just print it
557-
fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
562+
/// If this method should be re-called, it returns `false`.
563+
fn create_vscode_settings_maybe(config: &Config) -> io::Result<bool> {
558564
let (current_hash, historical_hashes) = SETTINGS_HASHES.split_last().unwrap();
559565
let vscode_settings = config.src.join(".vscode").join("settings.json");
560566
// If None, no settings.json exists
@@ -567,7 +573,7 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
567573
hasher.update(&current);
568574
let hash = hex::encode(hasher.finalize().as_slice());
569575
if hash == *current_hash {
570-
return Ok(());
576+
return Ok(true);
571577
} else if historical_hashes.contains(&hash.as_str()) {
572578
mismatched_settings = Some(true);
573579
} else {
@@ -593,7 +599,7 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
593599
Some(PromptResult::Print) => false,
594600
_ => {
595601
println!("Ok, skipping settings!");
596-
return Ok(());
602+
return Ok(true);
597603
}
598604
};
599605
if should_create {
@@ -620,5 +626,5 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
620626
} else {
621627
println!("\n{RUST_ANALYZER_SETTINGS}");
622628
}
623-
Ok(())
629+
Ok(should_create)
624630
}

0 commit comments

Comments
 (0)