Skip to content

Commit

Permalink
Make rustup override and rust-toolchain.toml hierarchical
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Sep 25, 2023
1 parent b7d9c87 commit 2946b70
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,15 @@ impl Cfg {
dir: &Path,
settings: &Settings,
) -> Result<Option<(OverrideFile, OverrideReason)>> {
let mut override_ = None;

let notify = self.notify_handler.as_ref();
let mut dir = Some(dir);

while let Some(d) = dir {
for d in std::iter::successors(Some(dir), |d| d.parent()) {
// First check the override database
if let Some(name) = settings.dir_override(d, notify) {
let reason = OverrideReason::OverrideDB(d.to_owned());
return Ok(Some((name.into(), reason)));
update_override(&mut override_, name.into(), reason);
}

// Then look for 'rust-toolchain' or 'rust-toolchain.toml'
Expand Down Expand Up @@ -662,13 +663,11 @@ impl Cfg {
}

let reason = OverrideReason::ToolchainFile(toolchain_file);
return Ok(Some((override_file, reason)));
update_override(&mut override_, override_file, reason);
}

dir = d.parent();
}

Ok(None)
Ok(override_)
}

fn parse_override_file<S: AsRef<str>>(
Expand Down

0 comments on commit 2946b70

Please sign in to comment.