diff --git a/src/cargo/util/context/mod.rs b/src/cargo/util/context/mod.rs index 5bd30a43626..ab283aa2481 100644 --- a/src/cargo/util/context/mod.rs +++ b/src/cargo/util/context/mod.rs @@ -1581,20 +1581,21 @@ impl GlobalContext { where F: FnMut(&Path) -> CargoResult<()>, { - let mut seen = HashSet::new(); + let mut seen_dir = HashSet::new(); for current in paths::ancestors(pwd, self.search_stop_path.as_deref()) { - if let Some(path) = self.get_file_path(¤t.join(".cargo"), "config", true)? { + let config_root = current.join(".cargo"); + if let Some(path) = self.get_file_path(&config_root, "config", true)? { walk(&path)?; - seen.insert(path); } + seen_dir.insert(config_root); } // Once we're done, also be sure to walk the home directory even if it's not // in our history to be sure we pick up that standard location for // information. - if let Some(path) = self.get_file_path(home, "config", true)? { - if !seen.contains(&path) { + if !seen_dir.contains(home) { + if let Some(path) = self.get_file_path(home, "config", true)? { walk(&path)?; } } diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs index 2582670a736..8f9092c2fb2 100644 --- a/tests/testsuite/config.rs +++ b/tests/testsuite/config.rs @@ -314,8 +314,6 @@ f1 = 1 .with_stderr_data(str![[r#" [WARNING] `[ROOT]/home/.cargo/config` is deprecated in favor of `config.toml` [NOTE] if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml` -[WARNING] `[ROOT]/home/.cargo/config` is deprecated in favor of `config.toml` -[NOTE] if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml` "#]]) .run();