Skip to content

Commit 6d62d29

Browse files
Rollup merge of rust-lang#104027 - ted-tanner:issue-103697-fix, r=jyn514
Place config.toml in current working directory if config not found Fixes an issue where bootsrapping a Rust build would place `config.toml` in `{src_root}` rather than the current working directory rust-lang#103697
2 parents 593d0cc + 66e8a29 commit 6d62d29

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/bootstrap/bin/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() {
3535

3636
// NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the
3737
// changelog warning, not the `x.py setup` message.
38-
let suggest_setup = !config.config.exists() && !matches!(config.cmd, Subcommand::Setup { .. });
38+
let suggest_setup = config.config.is_none() && !matches!(config.cmd, Subcommand::Setup { .. });
3939
if suggest_setup {
4040
println!("warning: you have not made a `config.toml`");
4141
println!(

src/bootstrap/config.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub struct Config {
8080
pub keep_stage_std: Vec<u32>,
8181
pub src: PathBuf,
8282
/// defaults to `config.toml`
83-
pub config: PathBuf,
83+
pub config: Option<PathBuf>,
8484
pub jobs: Option<u32>,
8585
pub cmd: Subcommand,
8686
pub incremental: bool,
@@ -926,8 +926,10 @@ impl Config {
926926
// Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path,
927927
// but not if `config.toml` hasn't been created.
928928
let mut toml = if !using_default_path || toml_path.exists() {
929+
config.config = Some(toml_path.clone());
929930
get_toml(&toml_path)
930931
} else {
932+
config.config = None;
931933
TomlConfig::default()
932934
};
933935

@@ -942,7 +944,6 @@ impl Config {
942944
}
943945

944946
config.changelog_seen = toml.changelog_seen;
945-
config.config = toml_path;
946947

947948
let build = toml.build.unwrap_or_default();
948949

src/bootstrap/setup.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl fmt::Display for Profile {
8282
}
8383

8484
pub fn setup(config: &Config, profile: Profile) {
85-
let path = &config.config;
85+
let path = &config.config.clone().unwrap_or(PathBuf::from("config.toml"));
8686

8787
if path.exists() {
8888
eprintln!(

0 commit comments

Comments
 (0)