Skip to content

Commit 15bf1cd

Browse files
committed
Make find_override_from_dir_walk() hierarchical
1 parent 3f5e217 commit 15bf1cd

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/config.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::borrow::Cow;
21
use std::fmt::{self, Display};
32
use std::io;
43
use std::path::{Path, PathBuf};
54
use std::process::Command;
65
use std::str::FromStr;
76
use std::sync::Arc;
7+
use std::{borrow::Cow, iter};
88

99
use anyhow::{anyhow, bail, Context, Result};
1010
use derivative::Derivative;
@@ -580,13 +580,15 @@ impl Cfg {
580580
dir: &Path,
581581
settings: &Settings,
582582
) -> Result<Option<(OverrideFile, OverrideReason)>> {
583+
let mut override_ = None;
584+
583585
let notify = self.notify_handler.as_ref();
584586

585587
for d in iter::successors(Some(dir), |d| d.parent()) {
586588
// First check the override database
587589
if let Some(name) = settings.dir_override(d, notify) {
588590
let reason = OverrideReason::OverrideDB(d.to_owned());
589-
return Ok(Some((name.into(), reason)));
591+
update_override(&mut override_, name.into(), reason);
590592
}
591593

592594
// Then look for 'rust-toolchain' or 'rust-toolchain.toml'
@@ -661,11 +663,15 @@ impl Cfg {
661663
}
662664

663665
let reason = OverrideReason::ToolchainFile(toolchain_file);
664-
return Ok(Some((override_file, reason)));
666+
update_override(&mut override_, override_file, reason);
667+
}
668+
669+
if override_.is_some() {
670+
break;
665671
}
666672
}
667673

668-
Ok(None)
674+
Ok(override_)
669675
}
670676

671677
fn parse_override_file<S: AsRef<str>>(

0 commit comments

Comments
 (0)