Skip to content

Commit 8f8f4ca

Browse files
majaharami3l
authored andcommitted
Make find_override_from_dir_walk return OverrideCfg
1 parent 2c0f86a commit 8f8f4ca

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/config.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,10 @@ impl Cfg {
576576
// Then walk up the directory tree from 'path' looking for either the
577577
// directory in the override database, or a `rust-toolchain{.toml}` file,
578578
// in that order.
579-
else if let Some((override_file, active_reason)) = self.settings_file.with(|s| {
579+
else if let Some((override_cfg, active_reason)) = self.settings_file.with(|s| {
580580
self.find_override_from_dir_walk(path, s)
581581
})? {
582-
Some((OverrideCfg::from_file(self, override_file)?, active_reason))
582+
Some((override_cfg, active_reason))
583583
}
584584
// Otherwise, there is no override.
585585
else {
@@ -593,15 +593,24 @@ impl Cfg {
593593
&self,
594594
dir: &Path,
595595
settings: &Settings,
596-
) -> Result<Option<(OverrideFile, ActiveReason)>> {
596+
) -> Result<Option<(OverrideCfg, ActiveReason)>> {
597597
let notify = self.notify_handler.as_ref();
598598
let mut dir = Some(dir);
599599

600600
while let Some(d) = dir {
601601
// First check the override database
602602
if let Some(name) = settings.dir_override(d, notify) {
603603
let reason = ActiveReason::OverrideDB(d.to_owned());
604-
return Ok(Some((name.into(), reason)));
604+
// Note that `rustup override set` fully resolves it's input
605+
// before writing to settings.toml, so resolving here may not
606+
// be strictly necessary (could instead model as ToolchainName).
607+
// However, settings.toml could conceivably be hand edited to
608+
// have an unresolved name. I'm just preserving pre-existing
609+
// behaviour by choosing ResolvableToolchainName here.
610+
let toolchain_name = ResolvableToolchainName::try_from(name)?
611+
.resolve(&get_default_host_triple(settings))?;
612+
let override_cfg = toolchain_name.into();
613+
return Ok(Some((override_cfg, reason)));
605614
}
606615

607616
// Then look for 'rust-toolchain' or 'rust-toolchain.toml'
@@ -674,7 +683,8 @@ impl Cfg {
674683
}
675684

676685
let reason = ActiveReason::ToolchainFile(toolchain_file);
677-
return Ok(Some((override_file, reason)));
686+
let override_cfg = OverrideCfg::from_file(self, override_file)?;
687+
return Ok(Some((override_cfg, reason)));
678688
}
679689

680690
dir = d.parent();

0 commit comments

Comments
 (0)